IEEERemainder Method

Math.IEEERemainder Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

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

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

'Declaration
Public Shared Function IEEERemainder ( _
	x As Double, _
	y As Double _
) As Double

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()

Class Example
   Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
      Dim doubleResult As Double
      Dim divisor As Double

      Dim str1 As [String] = "The IEEE remainder of {0:e}/{1:f} is {2:e}"
      divisor = 2.0
      outputBlock.Text += String.Format("{0}Divide two double-precision floating-point values:", vbCrLf) & vbCrLf
      doubleResult = Math.IEEERemainder([Double].MaxValue, divisor)
      outputBlock.Text &= "1) "
      outputBlock.Text += String.Format(str1, [Double].MaxValue, divisor, doubleResult) & vbCrLf

      divisor = 3.0
      doubleResult = Math.IEEERemainder([Double].MaxValue, divisor)
      outputBlock.Text &= "2) "
      outputBlock.Text += String.Format(str1, [Double].MaxValue, divisor, doubleResult) & vbCrLf
      outputBlock.Text &= "Note that two positive numbers can yield a negative remainder." & vbCrLf
   End Sub 
End Class 
'
'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.


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft