cc [ flags ] -I/usr/local/include file(s) -L/usr/local/lib -lmcw [ ... ] #include <mathcw.h> #include <cvtocw.h> extern const char * cvtogf (float x, int min_width, int p_digits, int e_digits, int g_digits, int base,
int flags); extern const char * cvtog (double x, int min_width, int p_digits, int e_digits, int g_digits, int base,
int flags); extern const char * cvtogl (long double x, int min_width, int p_digits, int e_digits, int g_digits, int base,
int flags); extern const char * cvtogw (__float80 x, int min_width, int p_digits, int e_digits, int g_digits, int base,
int flags); extern const char * cvtogq (__float128 x, int min_width, int p_digits, int e_digits, int g_digits, int base,
int flags); extern const char * cvtogll (long_long_double x, int min_width, int p_digits, int e_digits, int g_digits,
int flags); extern const char * cvtogdf (decimal_float x, int min_width, int p_digits, int e_digits, int g_digits,
int flags); extern const char * cvtogd (decimal_double x, int min_width, int p_digits, int e_digits, int g_digits,
int flags); extern const char * cvtogdl (decimal_long_double x, int min_width, int p_digits, int e_digits, int g_digits,
int flags); extern const char * cvtogdll (decimal_long_long_double x, int min_width, int p_digits, int e_digits,
int g_digits, int flags);
NB: Functions with prototypes containing underscores in type names may be available only with certain extended compilers.
2@1.100_100_100_001_111_110_111@e+1 8@3.110_375_524_210_264_302_151_423_063_050_560_067_00@e+0 10@3.14159_26535_89793_23846_26433_83279_50241@e+00000_00000 +10@3.141_592_653_589_793@e+000_000 16@3.243_f6a_888_5a3_08d_313_199@e+0 36@3.53i5g@e+0
The base and the exponent are always decimal values, and the exponent is always given as a power of the base.
Infinity is output as inf or INF, and may be signed if that feature is selected by the flags argument.
NaN is output as described for cvton(3CW).
The min_width argument specifies the minimum field width. A shorter value is padded with spaces or zeros and justified, according to specification of the flags argument. A negative value for min_width is treated as a zero value.
The p_digits argument specifies the desired precision of the output number, and is the number of digits following the point. There is always one additional digit before the point. A zero value for p_digits means that there is only one significant digit in the output.
A negative value for p_digits requests automatic determination of the precision needed to represent the number exactly, if the input or output base is an nonnegative integer power of the other, or sufficiently precisely for correct round-trip conversion, according to Goldberg's formula (Comm. ACM 10(2), 105---106, February 1967).
The e_digits argument specifies the number of exponent digits required. Padding zero digits are supplied on the left, if needed. The exponent of a zero value is always reported as zero, even though in decimal floating-point arithmetic, other values are possible.
The g_digits argument specifies the number of digits in a group in the significand and exponent. Underscores separate groups, counting away from the binary point of the significand, and from the right of the exponent. A zero or negative value of g_digits suppresses digit grouping.
The base argument is the output number base, a value in the range 2 ... 36. A value outside that range is ignored and replaced internally by 10.
The flags argument contains the logical OR (or arithmetic sum, as long as there are no repetitions) of these symbolic flags defined in the header file <cvtocw.h> (some have alternate names shown in the center column):
CVTO_NONE Placeholder for no flags. CVTO_E_STYLE Use %e-style conversion. CVTO_FILL_WITH_ZERO CVTO_FLAG_ZERO Pad with leading zeros. CVTO_F_STYLE Use %f-style conversion. CVTO_G_STYLE Use %g-style conversion. CVTO_JUSTIFY_CENTER CVTO_FLAG_EQUALS Center value in field width. CVTO_JUSTIFY_LEFT CVTO_FLAG_MINUS Left-justify value in field width. CVTO_JUSTIFY_RIGHT Right-justify value in field width. CVTO_SHOW_EXACT_ZERO Show exact zero as 0. CVTO_SHOW_PLUS CVTO_FLAG_PLUS Show plus sign. CVTO_SHOW_PLUS_AS_SPACE CVTO_FLAG_SPACE Show plus sign as space. CVTO_SHOW_POINT CVTO_FLAG_SHARP Show point when no fractional digits. CVTO_SHOW_SUBNORMAL Show subnormals with leading zeros. CVTO_SHOW_UPPERCASE Show value in uppercase. CVTO_TRIM_TRAILING_ZEROS CVTO_FLAG_SLASH Trim trailing fractional zero digits.
All applications should take care to avoid calling this function more than once in the same expression or argument list, because the result buffer can be correct for only one of those calls, unless a copy is made immediately.