C MathIEEERemainder 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.

IEEERemainderDouble, 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

Math.IEEERemainder(Double x, Double y)

where

Parameter Description
x The dividend.
y The divisor.

Return Value

The method returns reminder as Double value.

Example 1 IEEERemainderx, y

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

C# Program

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.