Прочетете на английски Редактиране

Споделяне чрез


MathF.IEEERemainder(Single, Single) Method

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Returns the remainder resulting from the division of a specified number by another specified number.

C#
public static float IEEERemainder(float x, float y);

Parameters

x
Single

The numerator

y
Single

The denominator

Returns

The result of dividing x by y

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

Продукт Версии
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Standard 2.0 (package-provided), 2.1