Edit

Share via


Floating-point primitives

Microsoft-specific primitive functions that are used to implement some standard C runtime library (CRT) floating-point functions. They're documented here for completeness, but aren't recommended for use. Some of these functions are noted as unused, because they're known to have issues in precision, exception handling, and conformance to IEEE-754 behavior. They exist in the library only for backward compatibility. For correct behavior, portability, and adherence to standards, prefer the standard floating-point functions over these functions.

By default, this function's global state is scoped to the application. To change this behavior, see Global state in the CRT.

_dclass, _ldclass, _fdclass

Syntax

short __cdecl _dclass(double x);
short __cdecl _ldclass(long double x);
short __cdecl _fdclass(float x);

Parameters

x
Floating-point function argument.

Remarks

These floating-point primitives implement the C versions of the CRT macro fpclassify for floating-point types. The classification of the argument x is returned as one of these constants, defined in math.h:

Value Description
FP_NAN A quiet, signaling, or indeterminate NaN
FP_INFINITE A positive or negative infinity
FP_NORMAL A positive or negative normalized non-zero value
FP_SUBNORMAL A positive or negative subnormal (denormalized) value
FP_ZERO A positive or negative zero value

For more detail, you can use the Microsoft-specific _fpclass, _fpclassf functions. Use the fpclassify macro or function for portability.

_dsign, _ldsign, _fdsign

Syntax

int __cdecl _dsign(double x);
int __cdecl _ldsign(long double x);
int __cdecl _fdsign(float x);

Parameters

x
Floating-point function argument.

Remarks

These floating-point primitives implement the signbit macro or function in the CRT. They return a non-zero value if the sign bit is set in the significand (mantissa) of the argument x. Otherwise, they return 0 if the sign bit isn't set.

_dpcomp, _ldpcomp, _fdpcomp

Syntax

int __cdecl _dpcomp(double x, double y);
int __cdecl _ldpcomp(long double x, long double y);
int __cdecl _fdpcomp(float x, float y);

Parameters

x, y
Floating-point function arguments.

Remarks

These floating-point primitives take two arguments, x and y, and return a value that shows their ordering relationship, expressed as the bitwise or of these constants, defined in math.h:

Value Description
_FP_LT x can be considered less than y
_FP_EQ x can be considered equal to y
_FP_GT x can be considered greater than y

These primitives implement the isgreater, isgreaterequal, isless, islessequal, islessgreater, and isunordered macros and functions in the CRT.

_dtest, _ldtest, _fdtest

Syntax

short __cdecl _dtest(double* px);
short __cdecl _ldtest(long double* px);
short __cdecl _fdtest(float* px);

Parameters

px
Pointer to a floating-point argument.

Remarks

These floating-point primitives implement the C++ versions of the CRT function fpclassify for floating-point types. The argument x is evaluated and the classification is returned as one of these constants, defined in math.h:

Value Description
FP_NAN A quiet, signaling, or indeterminate NaN
FP_INFINITE A positive or negative infinity
FP_NORMAL A positive or negative normalized non-zero value
FP_SUBNORMAL A positive or negative subnormal (denormalized) value
FP_ZERO A positive or negative zero value

For more detail, you can use the Microsoft-specific _fpclass, _fpclassf functions. Use the fpclassify function for portability.

_d_int, _ld_int, _fd_int

Syntax

short __cdecl _d_int(double* px, short exp);
short __cdecl _ld_int(long double* px, short exp);
short __cdecl _fd_int(float* px, short exp);

Parameters

px
Pointer to a floating-point argument.

exp
An exponent as an integral type.

Remarks

These floating-point primitives take a pointer to a floating-point value px and an exponent value exp, and remove the fractional part of the floating-point value below the given exponent, if possible. The value returned is the result of fpclassify on the input value in px if it's a NaN or infinity, and on the output value in px otherwise.

_dscale, _ldscale, _fdscale

Syntax

short __cdecl _dscale(double* px, long exp);
short __cdecl _ldscale(long double* px, long exp);
short __cdecl _fdscale(float* px, long exp);

Parameters

px
Pointer to a floating-point argument.

exp
An exponent as an integral type.

Remarks

These floating-point primitives take a pointer to a floating-point value px and an exponent value exp, and scale the value in px by 2exp, if possible. The value returned is the result of fpclassify on the input value in px if it's a NaN or infinity, and on the output value in px otherwise. For portability, prefer the ldexp, ldexpf, ldexpl functions.

_dunscale, _ldunscale, _fdunscale

Syntax

short __cdecl _dunscale(short* pexp, double* px);
short __cdecl _ldunscale(short* pexp, long double* px);
short __cdecl _fdunscale(short* pexp, float* px);

Parameters

pexp
A pointer to an exponent as an integral type.

px
Pointer to a floating-point argument.

Remarks

These floating-point primitives break down the floating-point value pointed at by px into a significand (mantissa) and an exponent, if possible. The significand is scaled such that the absolute value is greater than or equal to 0.5 and less than 1.0. The exponent is the value n, where the original floating-point value is equal to the scaled significand times 2n. This integer exponent n is stored at the location pointed to by pexp. The value returned is the result of fpclassify on the input value in px if it's a NaN or infinity, and on the output value otherwise. For portability, prefer the frexp, frexpf, frexpl functions.

_dexp, _ldexp, _fdexp

Syntax

short __cdecl _dexp(double* px, double y, long exp);
short __cdecl _ldexp(long double* px, long double y, long exp);
short __cdecl _fdexp(float* px, float y, long exp);

Parameters

y
Floating-point function argument.

px
Pointer to a floating-point argument.

exp
An exponent as an integral type.

Remarks

These floating-point primitives construct a floating-point value in the location pointed at by px equal to y * 2exp. The value returned is the result of fpclassify on the input value in y if it's a NaN or infinity, and on the output value in px otherwise. For portability, prefer the ldexp, ldexpf, ldexpl functions.

_dnorm, _fdnorm

Syntax

short __cdecl _dnorm(unsigned short* ps);
short __cdecl _fdnorm(unsigned short* ps);

Parameters

ps
Pointer to the bitwise representation of a floating-point value expressed as an array of unsigned short.

Remarks

These floating-point primitives normalize the fractional part of an underflowed floating-point value and adjust the characteristic, or biased exponent, to match. The value is passed as the bitwise representation of the floating-point type converted to an array of unsigned short through the _double_val, _ldouble_val, or _float_val type-punning union declared in math.h. The return value is the result of fpclassify on the input floating-point value if it's a NaN or infinity, and on the output value otherwise.

_dpoly, _ldpoly, _fdpoly

Syntax

double __cdecl _dpoly(double x, double const* table, int n);
long double __cdecl _ldpoly(long double x, long double const* table, int n);
float __cdecl _fdpoly(float x, _float const* table, int n);

Parameters

x
Floating-point function argument.

table
Pointer to a table of constant coefficients for a polynomial.

n
Order of the polynomial to evaluate.

Remarks

These floating-point primitives return the evaluation of x in the polynomial of order n whose coefficients are represented by the corresponding constant values in table. For example, if table[0] = 3.0, table[1] = 4.0, table[2] = 5.0, and n = 2, it represents the polynomial 5.0x2 + 4.0x + 3.0. If this polynomial is evaluated for x of 2.0, the result is 31.0. These functions aren't used internally.

_dlog, _dlog, _dlog

Syntax

double __cdecl _dlog(double x, int base_flag);
long double __cdecl _ldlog(long double x, int base_flag);
float __cdecl _fdlog(float x, int base_flag);

Parameters

x
Floating-point function argument.

base_flag
Flag that controls the base to use, 0 for base e and non-zero for base 10.

Remarks

These floating-point primitives return the natural log of x (ln(x) or loge(x)), when base_flag is 0. They return the log base 10 of x, or log10(x), when base_flag is non-zero. These functions aren't used internally. For portability, prefer the functions log, logf, logl, log10, log10f, and log10l.

_dsin, _ldsin, _fdsin

Syntax

double __cdecl _dsin(double x, unsigned int quadrant);
long double __cdecl _ldsin(long double x, unsigned int quadrant);
float __cdecl _fdsin(float x, unsigned int quadrant);

Parameters

x
Floating-point function argument.

quadrant
Quadrant offset of 0, 1, 2, or 3 to use to produce sin, cos, -sin, and -cos results.

Remarks

These floating-point primitives return the sine of x offset by the quadrant modulo 4. Effectively, they return the sine, cosine, -sine, and -cosine of x when quadrant modulo 4 is 0, 1, 2, or 3, respectively. These functions aren't used internally. For portability, prefer the sin, sinf, sinl, cos, cosf, cosl functions.

Requirements

Header: <math.h>

For more compatibility information, see Compatibility.

See also

Math and floating-point support
fpclassify
_fpclass, _fpclassf
isfinite, _finite, _finitef
isinf
isnan, _isnan, _isnanf
isnormal
cos, cosf, cosl
frexp, frexpf, frexpl
ldexp, ldexpf, ldexpl
log, logf, logl, log10, log10f, log10l
sin, sinf, sinl