Data Conversion

Below is several notes on Data Conversion: something funny that we need regularly.

---------------------------
1. FLOAT TO STRING

use this function:
_gcvt

the format is
char *_gcvt( double value, int digits, char *buffer );

value: the floating point number we wish to convert.
digits: number of decimal place.
buffer: storage location for result


to use it, take a look at this sample:

char buffer[50];
double source = -3.1415e5;
_gcvt( source, 2, buffer );

then, we have buffer that we can treat as string value.

No comments:

Post a Comment