Home  |  Delphi .net Home  |  System.Math  |  IEEERemainder Method

IEEERemainder
Method
Remainder from the division of 2 floating point numbers to IEEE standards
 Math Class System NameSpace
 CF 1 Procedure IEEERemainder ( X : Double; Y : Double ) ; Static;
CF : Methods with this mark are Compact Framework Compatible
 Description IEEERemainder gives the remainder when dividing two floating point numbers. The mechanics of the process adhere to IEEE standards, but are not intuitive.   The algorithm used is as follows:   Quotient        = X / Y   RoundedQuotient = Round(Quotient)   Remainder       = X - (Y * RoundedQuotient)   Note : The Round function uses so-called Bankers rules : rounding is to the nearest whole integer except that a value of exactly *.5 always gets to the nearest even integer. Notes Static methods are not methods of an object - they are simply class functions or procedures available at any time. References Round Microsoft MSDN Links System System.Math Author links Buy Website Traffic at  Buywebsitetrafficexperts.com  Buy Proxies at Buyproxies.io

 Illustrating the peculiarities of IEEERemainder program Project1; {\$APPTYPE CONSOLE} var   float : Double; begin  // 10/5 gives quotient of 2.0 which gets rounded to 2  // The returned remainder = 10 - (5 * 2) = 0   float := System.Math.IEEERemainder(10, 5);   Console.WriteLine('Remainder of 10  /5 = {0}', float.ToString);   // 12/5 gives quotient of 2.4 which gets rounded to 2  // The returned remainder = 12 - (5 * 2) = 2   float := System.Math.IEEERemainder(12, 5);   Console.WriteLine('Remainder of 12  /5 = {0}', float.ToString);   // 12.5/5 gives quotient of 2.5 which gets rounded to 2  // The returned remainder = 12.5 - (5 * 2) = 2.5   float := System.Math.IEEERemainder(12.5, 5);   Console.WriteLine('Remainder of 12.5/5 = {0}', float.ToString);   // 13/5 gives quotient of 2.6 which gets rounded to 3  // The returned remainder = 13 - (5 * 3) = -2   float := System.Math.IEEERemainder(13, 5);   Console.WriteLine('Remainder of 13  /5 = {0}', float.ToString);   // This illustrates Banker's rounding to the nearest even integer  // 17.5/5 gives quotient of 3.5 which gets rounded to 4  // The returned remainder = 17.5 - (5 * 4) = -2.5   float := System.Math.IEEERemainder(17.5, 5);   Console.WriteLine('Remainder of 17.5/5 = {0}', float.ToString);   // Divide by zero returns NaN - Not a Number   float := System.Math.IEEERemainder(1, 0);   Console.WriteLine('Remainder of  1  /0 = {0}', float.ToString);   Console.ReadLine; end. Remainder of 10  /5 = 0   Remainder of 12  /5 = 2   Remainder of 12.5/5 = 2.5   Remainder of 13  /5 = -2   Remainder of 17.5/5 = -2.5   Remainder of  1  /0 = NaN