dectoasc()

Formats a decimal value.

Syntax

mint dectoasc(dec_t *np, char *cp, mint len, mint right);
  1. np is a pointer to the decimal structure to convert to a text string.
  2. cp is a pointer to the first byte of the character buffer to hold the text string.
  3. len is the size of the string buffer, in bytes, minus 1 for the null terminator.
  4. right is an integer that indicates the number of decimal places to the right of the decimal point.
  5. Because the character string that dectoasc() returns is not null terminated, your program must add a null character to the string before you print it.

Returns

Table 1. Return codes
Code Description
0 The conversion was successful.
<0 The conversion failed.

Usage

To convert a decimal value to an ASCII string, specifying the length of the string and the number of digits to the right of the decimal point.