C# Math.IEEERemainder() – Examples

In this tutorial, we will learn about the C# Math.IEEERemainder() method, and learn how to use this method to find reminder of x when divided by y, with the help of examples.

IEEERemainder(Double, Double)

Math.IEEERemainder(x, y) returns the remainder resulting from the division of x by y.

If x/y falls halfway between two integers, the even integer is returned).

Syntax

The syntax of IEEERemainder() method is

</>
Copy
Math.IEEERemainder(Double x, Double y)

where

ParameterDescription
xThe dividend.
yThe divisor.

Return Value

The method returns reminder as Double value.

Example 1 – IEEERemainder(x, y)

In this example, we will take different values for x, y; and compute reminder of x/y using Math.IEEERemainder() method.

C# Program

</>
Copy
using System;
 
class Example {
    static void Main(string[] args) {
        Double x, y, result;

        x = 10;
        y = 4;
        result = Math.IEEERemainder(x, y);
        Console.WriteLine($"IEEERemainder({x}, {y}) = {result}");

        x = 7.9;
        y = 3;
        result = Math.IEEERemainder(x, y);
        Console.WriteLine($"IEEERemainder({x}, {y}) = {result}");

        x = -10;
        y = 5;
        result = Math.IEEERemainder(x, y);
        Console.WriteLine($"IEEERemainder({x}, {y}) = {result}");
    }
}

Output

IEEERemainder(10, 4) = 2
IEEERemainder(7.9, 3) = -1.0999999999999996
IEEERemainder(-10, 5) = -0

Conclusion

In this C# Tutorial, we have learnt the syntax of C# Math.IEEERemainder() method, and also learnt how to use this method with the help of C# example programs.