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.
Assembly: mscorlib (in mscorlib.dll)
Return Value
Type: System.DoubleA 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.
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.
Show: