What is Math.IEEERemainder() in C#?

C# has a built-in Math class that provides useful mathematical functions and operations. The class has the IEEERemainder() function, which is used to compute the remainder resulting from the division of two specified numbers.

Syntax

public static double IEEERemainder (double param1, double param2);

Parameters

  • param1: This is a double number that specifies the dividend.
  • param2: This is a double number that specifies the divisor.

Return value

remainder = dividend - divisor*Quotient

where Quotient =  Math.Round(dividend/divisor)
  • Double: This returns a Double number specifying the remainder.
  • 0: If remainder = 0, this returns:
    • +0 if dividend > 0
    • -0 if dividend < 0
  • NaN: This returns NaN if divisor = 0.

Quotient is rounded to the nearest integer. It returns an even integer if halfway between two integers.

Example

using System;
class Educative
{
static void Main()
{
double result = Math.IEEERemainder(3, 2);
System.Console.WriteLine("IEEERemainder(3, 2) = "+ result);
double result1 = Math.IEEERemainder(3, 3);
System.Console.WriteLine("IEEERemainder(3, 3) = "+ result1);
double result2 = Math.IEEERemainder(3, 0);
System.Console.WriteLine("IEEERemainder(3, 0) = "+ result2);
}
}

Free Resources