MathF.IEEERemainder(Single, Single) Method

Definition

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

Parameters

x
Single

A dividend.

y
Single

A divisor.

Returns

A number equal to x - (y Q), where Q is the quotient of x / y rounded to the nearest integer (if x / y falls halfway between two integers, the even integer is returned).

If x - (y Q) is zero, the value +0 is returned if x is positive, or -0 if x is negative.

If y = 0, NaN is returned.

Remarks

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)  

Applies to