Table of Contents Previous topic Next topic

C COMPILER LIBRARY FUNCTIONS->Detailed Descriptions->_fcvt() _fcvtl

Summary

#include <stdlib.h>

char *_fcvt(double value, int count, int* dec, int* sign); | Convert floating point value to a string |

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

value | The number to be converted |

count | Number of digits after the decimal point |

dec | Pointer to integer for storage of decimal point position |

sign | Pointer to integer for storage of sign indicator |

The _fcvt() and _fcvtl() 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 after the decimal place. 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 _fcvt(), _fcvtl(), _ecvt() or _ecvtl().

The functions return a pointer to the string of digits.