mathnextafter Method (Single, Single) |
Gets the floating-point number that is next after fromNumber in the direction of towardNumber.
Namespace:
C
Assembly:
C.math (in C.math.dll) Version: 1.0.0.0 (1.0.0.0)
Syntaxpublic static float nextafter(
float fromNumber,
float towardNumber
)
Public Shared Function nextafter (
fromNumber As Single,
towardNumber As Single
) As Single
public:
static float nextafter(
float fromNumber,
float towardNumber
)
static member nextafter :
fromNumber : float32 *
towardNumber : float32 -> float32
Parameters
- fromNumber
- Type: SystemSingle
A floating-point number. - towardNumber
- Type: SystemSingle
A floating-point number.
Return Value
Type:
SingleThe floating-point number that is next after
fromNumber in the direction of
towardNumber.
Remarks
IEC 60559 recommends that fromNumber be returned whenever fromNumber == towardNumber.
These functions return towardNumber instead, which makes the behavior around zero consistent: nextafter(-0.0, +0.0)
returns +0.0 and nextafter(+0.0, -0.0) returns –0.0.
See nextafter in the C standard documentation.
ExamplesAssert.IsTrue(math.nextafter(0F, 0F) == 0F);
Assert.IsTrue(math.nextafter(-0F, 0F) == 0F;
Assert.IsTrue(math.nextafter(0F, -0F) == -0F);
Assert.IsTrue(math.nextafter(math.FLT_MIN, 0D) == math.FLT_DENORM_MAX);
Assert.IsTrue(math.nextafter(math.FLT_DENORM_MIN, 0F) == 0F);
Assert.IsTrue(math.nextafter(math.FLT_MIN, -0F) == math.FLT_DENORM_MAX);
Assert.IsTrue(math.nextafter(math.FLT_DENORM_MIN, -0F) == 0F);
Assert.IsTrue(math.nextafter(0F, System.Single.PositiveInfinity) == math.FLT_DENORM_MIN);
Assert.IsTrue(math.nextafter(-0F, System.Single.NegativeInfinity) == -math.FLT_DENORM_MIN);
Assert.IsTrue(math.nextafter(0F, 0F) = 0F);
Assert.IsTrue(math.nextafter(-0F, 0F) = 0F);
Assert.IsTrue(math.nextafter(0F, -0F) = -0F);
Assert.IsTrue(math.nextafter(math.FLT_MIN, 0F) = math.FLT_DENORM_MAX);
Assert.IsTrue(math.nextafter(math.FLT_DENORM_MIN, 0F) = 0F);
Assert.IsTrue(math.nextafter(math.FLT_MIN, -0F) = math.FLT_DENORM_MAX);
Assert.IsTrue(math.nextafter(math.FLT_DENORM_MIN, -0F) = 0F);
Assert.IsTrue(math.nextafter(0F, System.Single.PositiveInfinity) = math.FLT_DENORM_MIN);
Assert.IsTrue(math.nextafter(-0F, System.Single.NegativeInfinity) = -math.FLT_DENORM_MIN);
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
See Also