Udostępnij za pośrednictwem


Floating-Point Support

Many Microsoft run-time library functions require floating-point support from a math coprocessor or from the floating-point libraries that accompany the compiler. Floating-point support functions are loaded only if required.

When you use a floating-point type specifier in the format string of a call to a function in the printf or scanf family, you must specify a floating-point value or a pointer to a floating-point value in the argument list to tell the compiler that floating-point support is required.

To handle floating-point exceptions, refer to the sample code in the _fpieee_flt topic.

Floating-point precision of intermediate values are controlled by the functions _control87, _controlfp, __control87_2. By default, _controlfp's precision control is set to 53 bits (_PC_53). Linking with FP10.OBJ changes the default precision control to 64 bits (_PC_64). On the linker command line, FP10.OBJ must appear before LIBC.LIB, LIBCMT.LIB, or MSVCRT.LIB.

Floating-Point Functions

Routine

Use

.NET Framework equivalent

abs

Return absolute value of int

System::Math::Abs

acos, acosf

Calculate arccosine

System::Math::Acos

asin, asinf

Calculate arcsine

System::Math::Asin

atan, atanf, atan2, atan2f

Calculate arctangent

System::Math::Atan, System::Math::Atan2

atof, _atof_l, _wtof, _wtof_l

Convert character string to double-precision floating-point value

System::Convert::ToSingle, System::Convert::ToDouble

Bessel functions

Calculate Bessel functions _j0, _j1, _jn, _y0, _y1, _yn

Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.

_cabs

Find absolute value of complex number

Not applicable.

ceil, ceilf

Find integer ceiling

System::Math::Ceiling

_chgsign, _chgsignl

Reverse sign of double-precision floating-point or long double-precision floating-point argument

Not applicable.

_clear87, _clearfp

Get and clear floating-point status word

Not applicable.

_control87, _controlfp, __control87_2, _controlfp_s

Get old floating-point control word and set new control-word value

Not applicable.

_copysign, _copysignl

Return one value with sign of another

Not applicable.

cos, cosf, cosh, coshf

Calculate cosine

System::Math::Cos, System::Math::Cosh

difftime

Compute difference between two specified time values

System::DateTime::Subtract

div

Divide one integer by another, returning quotient and remainder

Not applicable.

_ecvt, _ecvt_s

Convert double to character string of specified length

System::Convert::ToString

exp, expf

Calculate exponential function

System::Math::Exp

fabs, fabsf

Find absolute value

System::Math::Abs

_fcvt, _fcvt_s

Convert double to string with specified number of digits following decimal point

System::Convert::ToString

_finite

Determine whether given double-precision floating-point value is finite

System::Double::IsInfinity

floor, floorf

Find largest integer less than or equal to argument

System::Math::Floor

fmod, fmodf

Find floating-point remainder

System::Math::IEEERemainder

_fpclass

Return status word containing information on floating-point class

System::Double::IsInfinity, System::Double::IsNegativeInfinity, System::Double::IsPositiveInfinity, System::Double::IsNan

_fpieee_flt

Invoke user-defined trap handler for IEEE floating-point exceptions

Not applicable.

_fpreset

Reinitialize floating-point math package

 

frexp

Calculate exponential value

Not applicable.

_gcvt, _gcvt_s

Convert floating-point value to character string

System::Convert::ToString

_hypot, hypotf

Calculate hypotenuse of right triangle

Not applicable.

_isnan

Check given double-precision floating-point value for not a number (NaN)

System::Double::IsNan

labs

Return absolute value of long

System::Math::Abs

ldexp

Calculate product of argument and 2 to specified power

System::Math::Pow

ldiv

Divide one long integer by another, returning quotient and remainder

Not applicable.

log, logf, log10, log10f

Calculate natural or base-10 logarithm.

System::Math::Log, System::Math::Log10

_logb

Extract exponential value of double-precision floating-point argument

Not applicable.

_lrotl, _lrotr

Shift unsigned long int left (_lrotl) or right (_lrotr)

Not applicable.

_matherr

Handle math errors

Not applicable.

__max

Return larger of two values

System::Math::Max

__min

Return smaller of two values

System::Math::Min

modf, modff

Split argument into integer and fractional parts

Not applicable.

_nextafter

Return next representable neighbor

Not applicable.

pow, powf

Calculate value raised to a power

System::Math::Pow

printf, _printf_l, wprintf, _wprintf_l, printf_s, _printf_s_l, wprintf_s, _wprintf_s_l

Write data to stdout according to specified format

System::Console::Write, System::Console::WriteLine

rand, rand_s

Get pseudorandom number

System::Random Class

_rotl, _rotr

Shift unsigned int left (_rotl) or right (_rotr)

Not applicable.

_scalb

Scale argument by power of 2

Not applicable.

scanf, wscanf, scanf_s, _scanf_s_l, wscanf_s, _wscanf_s_l

Read data from stdin according to specified format and write data to specified location

System::Console::Read, System::Console::ReadLine

_set_controlfp

set new control-word value

Not applicable.

sin, sinf, sinh, sinhf

Calculate sine or hyperbolic sine

System::Math::Sin, System::Math::Sinh

sqrt

Find square root

System::Math::Sqrt

srand

Initialize pseudorandom series

System::Random Class

_status87, _statusfp, _statusfp2

Get floating-point status word

Not applicable.

strtod, _strtod_l, wcstod, _wcstod_l

Convert character string to double-precision value

System::Convert::ToDouble

tan, tanf, tanh, tanhf

Calculate tangent or hyperbolic tangent

System::Math::Tan, System::Math::Tanh

See Also

Reference

Run-Time Routines by Category