CVTON 3CW "28 February 2007" "mathcw-1.00"

Table of contents


NAME

cvtonf, cvton, cvtonl, cvtonw, cvtonq, cvtonll, cvtondf, cvtond, cvtondl, cvtondll - convert NaN to string

SYNOPSIS

cc [ flags ] -I/usr/local/include file(s) -L/usr/local/lib -lmcw [ ... ]

#include <mathcw.h>
#include <cvtocw.h>

extern const char * cvtonf (float x, int flags);

extern const char * cvton (double x, int flags);

extern const char * cvtonl (long double x, int flags);

extern const char * cvtonw (__float80 x, int flags);

extern const char * cvtonq (__float128 x, int flags);

extern const char * cvtonll (long_long_double x, int flags);

extern const char * cvtondf (decimal_float x, int flags);

extern const char * cvtond (decimal_double x, int flags);

extern const char * cvtondl (decimal_long_double x, int flags);

extern const char * cvtondll (decimal_long_long_double x, int flags);

NB: Functions with prototypes containing underscores in type names may be available only with certain extended compilers.


DESCRIPTION

Convert a NaN to a string. On systems that support both quiet and signaling NaNs, the type of NaN is identified by a leading q or s. When only one type of NaN is supported (Intel IA-32, Java Virtual Machine, and possibly also the Microsoft .NET Framework Common Language Infrastructure (CLI) virtual machine, the NaN is reported as just nan.

The flags argument may contain flags defined in <cvtocw.h>, but the only ones tested are CVTO_SHOW_PLUS, CVTO_SHOW_PLUS_AS_SPACE, and CVTO_SHOW_UPPERCASE.

If the NaN has a nonzero payload in the significand (excluding the significand bit that distinguishes NaN and Infinity in binary floating-point formats), the payload is displayed as a parenthesized hexadecimal string, with leading zeros suppressed. Although NaNs in all floating-point designs have a sign, the sign has no significance. Examples include:

-nan
qnan
snan
-qnan(0x1234)
+snan(0xfeedface)

Unlike other members of the output conversion function family in the mathcw library, the NaN conversion functions do not support field widths or string justification, because they are normally invoked only from other conversion functions which do provide such control.

The flags argument contains the logical OR (or arithmetic sum, as long as there are no repetitions) of a subset of the 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_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_UPPERCASE                      Show value in uppercase.

RETURN VALUES

If the argument is not a NaN, return a NULL pointer. Otherwise, return a pointer to an internal static buffer containing the result string. The buffer is overwritten on subsequent calls to these functions.

CAVEATS

Because the result is accumulated in an internal static buffer, the function is not thread safe. Threaded applications should restrict use of this function to a single thread, or else carefully control access to it with exclusion locks.

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.


ERRORS

None.

SEE ALSO

cvtia(3CW), cvtib(3CW), cvtid(3CW), cvtig(3CW), cvtih(3CW), cvtio(3CW), cvtob(3CW), cvtod(3CW), cvtog(3CW), cvtoh(3CW), cvtoi(3CW), cvtoo(3CW).