The dectoasc() function

The dectoasc() function converts a decimal type number to a C char type value.

Syntax

mint dectoasc(dec_val, strng_val, len, right)
   dec_t *dec_val;
   char *strng_val;
   mint len;
   mint right;
dec_val
A pointer to the decimal structure that contains the value to convert to a text string.
strng_val
A pointer to the first byte of the character buffer where the dectoasc() function is to place the text string.
len
The size of strng_val, in bytes, minus 1 for the null terminator.
right
is an integer that indicates the number of decimal places to the right of the decimal point.

Usage

If right = -1, the decimal value of dec_val determines the number of decimal places.

If the decimal number does not fit into a character string of length len, dectoasc() converts the number to an exponential notation. If the number still does not fit, dectoasc() fills the string with asterisks. If the number is shorter than the string, dectoasc() left-justifies the number and pads it on the right with blanks.

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.

Return values

0
The conversion was successful.
-1
The conversion failed.