Crossware

Table of Contents        Previous topic       Next topic       

COMPILER LIBRARY FUNCTIONS->Detailed Descriptions->_ecvt() _ecvtl

Summary

#include <stdlib.h>

    
char *_ecvt(double value, int count, int* dec, int* sign);Convert floating point value to a string
char *_ecvtl(long double value, int count, int* dec, int* sign);Convert floating point value to a string

Parameters

    
valueThe number to be converted
countNumber of digits after the decimal point
dec  Pointer to integer for storage of decimal point position
signPointer to integer for storage of sign indicator
Description
The _ecvt() and _ecvtl() functions convert a floating-point number to a null-terminated character string.  The value argument is the number to be converted.  The digits of the converted value are stored in a statically allocated string and a null character ('\0') is appended to terminate it.  The count argument specifies the number of digits to be stored.  If there are fewer than count digits, the string is padded with zeros.
Only digits are stored in the string.  The position of the decimal point and the sign of the value are stored separately in integers provided by the caller.
The dec argument points to an integer into which a value will be placed indicating the position of the decimal point with respect to the beginning of the string.  A zero or negative value indicates that the decimal point lies to the left of the first digit in the string.
The sign argument points to an integer into which a value will be placed indicating the sign of value.  If this is zero, value is positive.  If it is non-zero, value is negative.
The string is statically allocated and will consequently be overwritten by subsequent calls to either _ecvt(), _ecvtl(), _fcvt() or _fcvtl().


Return Value
The functions return a pointer to the string of digits.