Mono Class Library: System.Math Overview | Members

System.Math.IEEERemainder Method

Returns the remainder resulting from the division of one specified double by another specified double. [Edit]

public static double IEEERemainder (double x, double y)

Parameters

x
A double that represents a dividend. [Edit]
y
A double that represents a divisor. [Edit]

Returns

A double whose value is as follows:

ValueDescription
x - (y Q),Q is the quotient of x/y rounded to the nearest integer (if x/y is exactly halfway between two integers, the even integer is returned).
+0Q is the quotient of x/y rounded to the nearest integer (if x/y is exactly halfway between two integers, the even integer is returned), x - (y Q) is zero, and x is positive.
-0Q is the quotient of x/y rounded to the nearest integer (if x/y is exactly halfway between two integers, the even integer is returned), x - (y Q) is zero, and x is negative.
double.NaNy = 0.
[Edit]

Remarks

This operation complies with the remainder operation defined in Section 5.1 of ANSI/IEEE Std 754-1985; IEEE Standard for Binary Floating-Point Arithmetic; Institute of Electrical and Electronics Engineers, Inc; 1985.

Note: For more information regarding the use of +0 and -0, see Section 3.1 of ANSI/IEEE Std 754-1985; IEEE Standard for Binary Floating-Point Arithmetic; Institute of Electrical and Electronics Engineers, Inc; 1985.

[Edit]

Example

The following example demonstrates using the Math.IEEERemainder(double, double) method.

C# Example
using System;

public class MathIEEERemainderExample
{

   public static void Main()
   {

      Double d1 = Math.IEEERemainder(3.54,0);
      Double d2 = Math.IEEERemainder(9.99,-3.33);
      Double d3 = Math.IEEERemainder(-9.99,3.33);
      Double d4 = Math.IEEERemainder(9.5,1.5);
      Console.WriteLine("Math.IEEERemainder(3.54,0) returns {0}", d1);
      Console.WriteLine("Math.IEEERemainder(9.99,-3.33) returns {0}", d2);
      Console.WriteLine("Math.IEEERemainder(-9.99,3.33) returns {0}", d3);
      Console.WriteLine("Math.IEEERemainder(9.5,1.5) returns {0}", d4);

   }

}

The output is

Math.IEEERemainder(3.54,0) returns NaN
Math.IEEERemainder(9.99,-3.33) returns 0
Math.IEEERemainder(-9.99,3.33) returns 0
Math.IEEERemainder(9.5,1.5) returns 0.5

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0