Define the functions required to turn double values into a string.
More...
|
static void | cvt (double arg, int ndigits, int *decpt, int *sign, char *buf, unsigned buf_size, int eflag) |
| Converts a floating-point number into a string representation. More...
|
|
void | ecvtbuf (double arg, int chars, int *decpt, int *sign, char *buf, unsigned buf_size) |
| Thif function transforms value into a string of digits inside buf , representing the whole part followed by the decimal part. More...
|
|
void | fcvtbuf (double arg, int decimals, int *decpt, int *sign, char *buf, unsigned buf_size) |
| Thif function transforms value into a string of digits inside buf , representing the whole part followed by the decimal part. More...
|
|
Define the functions required to turn double values into a string.
- Copyright
- (c) 2014-2024 This file is distributed under the MIT License. See LICENSE.md for details.
◆ cvt()
static void cvt |
( |
double |
arg, |
|
|
int |
ndigits, |
|
|
int * |
decpt, |
|
|
int * |
sign, |
|
|
char * |
buf, |
|
|
unsigned |
buf_size, |
|
|
int |
eflag |
|
) |
| |
|
static |
Converts a floating-point number into a string representation.
- Parameters
-
arg | The floating-point number to convert. |
ndigits | The number of digits to generate after the decimal point. |
decpt | A pointer to an integer that will store the position of the decimal point. |
sign | A pointer to an integer that will store the sign of the number (1 if negative, 0 otherwise). |
buf | A character buffer where the resulting string will be stored. |
buf_size | The size of the buffer. |
eflag | A flag indicating whether to use exponential notation (1 for exponential, 0 for standard). |
◆ ecvtbuf()
void ecvtbuf |
( |
double |
arg, |
|
|
int |
chars, |
|
|
int * |
decpt, |
|
|
int * |
sign, |
|
|
char * |
buf, |
|
|
unsigned |
buf_size |
|
) |
| |
Thif function transforms value
into a string of digits inside buf
, representing the whole part followed by the decimal part.
For instance, 512.765 will result in: decpt = 3 sign = 0 buf = "512765"
- Parameters
-
arg | The argument to turn into string. |
chars | The total number of digits. |
decpt | The position of the decimal point. |
sign | The sign of the number. |
buf | Buffer where the digits should be placed. |
buf_size | Dimension of the buffer. |
◆ fcvtbuf()
void fcvtbuf |
( |
double |
arg, |
|
|
int |
decimals, |
|
|
int * |
decpt, |
|
|
int * |
sign, |
|
|
char * |
buf, |
|
|
unsigned |
buf_size |
|
) |
| |
Thif function transforms value
into a string of digits inside buf
, representing the whole part followed by the decimal part.
For instance, 512.765 will result in: decpt = 3 sign = 0 buf = "512765"
- Parameters
-
arg | The argument to turn into string. |
decimals | The total number of digits to write after the decimal point. |
decpt | The position of the decimal point. |
sign | The sign of the number. |
buf | Buffer where the digits should be placed. |
buf_size | Dimension of the buffer. |