Syntax | #include <stdlib.h> char *ecvt(double value, int ndigit, int *decpt, int *sign); char *fcvt (double value, int ndigit, int *decpt, int *sign); char *gcvt (double value, int ndigit, char *buf); | |
Description |
returns a pointer to this string as its result. The output format corresponds to the %f format of printf(). The string begins with the first non-zero digit of the floating-point number, i.e. leading zeros are not included. The decimal character and a negative sign, if any, do not form a part of the string. However, value is a floating-point value that is to be edited for output. ndigit is the number of digits in the result string (calculated from the first non-zero digit of the floating-point number to be converted). If ndigit is less than the number of digits in value, the least significant digit is rounded. If ndigit is greater, zero padding is used for right justification. The accuracy of the converted number is restricted by the maximum number of significant digits that can be represented in the type decpt is the pointer to an integer specifying the position of the decimal character in the result string. If *decpt is a positive number, the position of the decimal character relative to the beginning of the result string is specified. If *decpt is a negative number or 0, the decimal character is to the left of the first digit. If the integer part of value cannot be represented in full with ndigit digits, *decpt is greater than ndigit. sign is the pointer to an integer specifying the sign of the result string. If *sign is 0, the sign is positive; if *sign is not 0: the sign is negative.
If ndigit is less than the number of digits in value after the decimal character, the least significant digit is rounded. If ndigit is greater, zero padding is used for right justification.
In addition the string contains a minus sign if the value is < 0, and the decimal character if value is not an integer. The decimal character used is based on the current locale and is determined there by the category Depending on the structure of the floating-point number to be converted, the output format corresponds to
ndigit is the number of digits in the result string (calculated as of the first non-zero digit from the floating-point number to be converted). *buf is the pointer to the converted string.
| |
Return val. |
| |
if successful. The string is terminated with the null byte ( | ||
|
| |
| *buf | if successful. The string is terminated with the null byte ( |
Notes | An invalid parameter, such as an Portable applications should use the
| |
See also |
|