Export (0) Print
Expand All

Math.IEEERemainder Method

Returns the remainder resulting from the division of a specified number by another specified number.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

public static double IEEERemainder(
	double x,
	double y
)

Parameters

x
Type: System.Double
A dividend.
y
Type: System.Double
A divisor.

Return Value

Type: System.Double
A number equal to x - (y Q), where Q is the quotient of x / y rounded to the nearest integer (if x / y falls halfway between two integers, the even integer is returned).
If x - (y Q) is zero, the value +0 is returned if x is positive, or -0 if x is negative.
If y = 0, NaN (Not-A-Number) is returned.

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.

The following example uses the IEEERemainder method to calculate the remainders of two division operations between a Double variable's maximum value and 2 and 3, respectively. The result is then printed to the console.


// This example demonstrates Math.IEEERemainder()
using System;

class Example
{
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      double doubleResult;
      double divisor;

      String str1 = "The IEEE remainder of {0:e}/{1:f} is {2:e}";
      divisor = 2.0;
      outputBlock.Text += "\nDivide two double-precision floating-point values:" + "\n";
      doubleResult = Math.IEEERemainder(Double.MaxValue, divisor);
      outputBlock.Text += "1) ";
      outputBlock.Text += String.Format(str1, Double.MaxValue, divisor, doubleResult) + "\n";

      divisor = 3.0;
      doubleResult = Math.IEEERemainder(Double.MaxValue, divisor);
      outputBlock.Text += "2) ";
      outputBlock.Text += String.Format(str1, Double.MaxValue, divisor, doubleResult) + "\n";
      outputBlock.Text += "Note that two positive numbers can yield a negative remainder." + "\n";
   }
}
/*
This example produces the following results:

   Divide two double-precision floating-point values:
   1) The IEEE remainder of 1.797693e+308/2.00 is 0.000000e+000
   2) The IEEE remainder of 1.797693e+308/3.00 is -1.000000e+000
   Note that two positive numbers can yield a negative remainder.

*/


Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions

ADD
Show:
© 2014 Microsoft