MentOS  0.8.0
The Mentoring Operating System
Macros | Functions
fcvt.c File Reference

Define the functions required to turn double values into a string. More...

Macros

#define __DEBUG_HEADER__   "[FCVT] "
 Change header.
 
#define __DEBUG_LEVEL__   LOGLEVEL_NOTICE
 Set log level.
 

Functions

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...
 

Detailed Description

Define the functions required to turn double values into a string.

Function Documentation

◆ 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
argThe floating-point number to convert.
ndigitsThe number of digits to generate after the decimal point.
decptA pointer to an integer that will store the position of the decimal point.
signA pointer to an integer that will store the sign of the number (1 if negative, 0 otherwise).
bufA character buffer where the resulting string will be stored.
buf_sizeThe size of the buffer.
eflagA 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
argThe argument to turn into string.
charsThe total number of digits.
decptThe position of the decimal point.
signThe sign of the number.
bufBuffer where the digits should be placed.
buf_sizeDimension 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
argThe argument to turn into string.
decimalsThe total number of digits to write after the decimal point.
decptThe position of the decimal point.
signThe sign of the number.
bufBuffer where the digits should be placed.
buf_sizeDimension of the buffer.