Click or drag to resize
mathnextafter Method (Double, Double)
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 double nextafter(
	double fromNumber,
	double towardNumber
)

Parameters

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

Return Value

Type: Double
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(0D, 0D) == 0D);
Assert.IsTrue(math.nextafter(-0D, 0D) == 0D;
Assert.IsTrue(math.nextafter(0D, -0D) == -0D);

Assert.IsTrue(math.nextafter(math.DBL_MIN, 0D) == math.DBL_DENORM_MAX);
Assert.IsTrue(math.nextafter(math.DBL_DENORM_MIN, 0D) == 0D);
Assert.IsTrue(math.nextafter(math.DBL_MIN, -0D) == math.DBL_DENORM_MAX);
Assert.IsTrue(math.nextafter(math.DBL_DENORM_MIN, -0D) == 0D);

Assert.IsTrue(math.nextafter(0D, System.Double.PositiveInfinity) == math.DBL_DENORM_MIN);
Assert.IsTrue(math.nextafter(-0D, System.Double.NegativeInfinity) == -math.DBL_DENORM_MIN);
See Also