Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> C#

Phương thức MathF.IEEERemainder() trong C#

Phương thức MathF.IEEERemainder() trong C# trả về phần dư từ phép chia một số cho một số khác theo tiêu chuẩn IEEE 754.

Cú pháp

public static float IEEERemainder (float dividend, double divisor);

Ví dụ

using System; 
public class Demo { 
    public static void Main(){ 
        float val1 = 90.5f; 
        float val2 = 13.5f; 
        float rem = MathF.IEEERemainder(val1, val2); 
        Console.WriteLine(rem); 
    } 
}

Kết quả

-4

Ví dụ khác

using System; 
public class Demo { 
    public static void Main(){ 
        float val1 = 0.0f; 
        float val2 = 1.0f; 
        float rem = MathF.IEEERemainder(val1, val2); 
        Console.WriteLine(rem); 
    } 
}

Kết quả

0