英語で読む

次の方法で共有


MathF.IEEERemainder(Single, Single) メソッド

定義

指定した数値を別の指定した数値で除算した結果の剰余を返します。

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

パラメーター

x
Single

分子

y
Single

分母

戻り値

xy で除算した結果

注釈

この操作は、ANSI/IEEE Std 754-1985 のセクション 5.1 で定義されている剰余演算に準拠しています。IEEE Standard for Binary Floating-Point Arithmetic;電気電子工学研究所, Inc;1985.

IEEERemainder メソッドは、剰余演算子と同じではありません。 どちらも除算後に剰余を返しますが、使用する数式は異なります。 IEEERemainder メソッドの数式は次のとおりです。

IEEERemainder = dividend - (divisor * MathF.Round(dividend / divisor))

これに対し、剰余演算子の数式は次のとおりです。

Remainder = (MathF.Abs(dividend) - (MathF.Abs(divisor) *
            (MathF.Floor(MathF.Abs(dividend) / MathF.Abs(divisor))))) *
            MathF.Sign(dividend)

適用対象

製品 バージョン
.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