IEEERemainder(Single, Single) Method
Returns the remainder resulting from the division of a specified number by another specified number.
public: static float IEEERemainder(float x, float y);
public static float IEEERemainder (float x, float y);
static member IEEERemainder : single * single -> single
Public Shared Function IEEERemainder (x As Single, y As Single) As Single
A number equal to
x - (
y Q), where Q is the quotient of
y rounded to the nearest integer (if
y falls halfway between two integers, the even integer is returned).
x - (
y Q) is zero, the value +0 is returned if
x is positive, or -0 if
x is negative.
y = 0, NaN is returned.
This operation complies with the remainder operation defined in Section 5.1 of ANSI/IEEE Std 754-1985; IEEE Standard for Binary Floating-Point Arithmetic; Institute of Electrical and Electronics Engineers, Inc; 1985.
The IEEERemainder method is not the same as the remainder operator. Although both return the remainder after division, the formulas they use are different. The formula for the IEEERemainder method is:
IEEERemainder = dividend - (divisor * MathF.Round(dividend / divisor))
In contrast, the formula for the remainder operator is:
Remainder = (MathF.Abs(dividend) - (MathF.Abs(divisor) * (MathF.Floor(MathF.Abs(dividend) / MathF.Abs(divisor))))) * MathF.Sign(dividend)