Click or drag to resize
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)
Syntax
public static float nextafter(
	float fromNumber,
	float towardNumber
)

Parameters

fromNumber
Type: SystemSingle
A floating-point number.
towardNumber
Type: SystemSingle
A floating-point number.

Return Value

Type: Single
The 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.

Examples
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, 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);
See Also