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

Abs
Method
Gets the absolute value of a number
 Math Class System NameSpace
 CF 1 Function Abs ( Value : SByte ) : Sbyte; Static; CF 2 Function Abs ( Value : SmallInt ) : SmallInt; Static; CF 3 Function Abs ( Value : ShortInt ) : ShortInt; Static; CF 4 Function Abs ( Value : Integer ) : Integer; Static; CF 5 Function Abs ( Value : Int64 ) : Int64; Static; CF 6 Function Abs ( Value : Single ) : Single; Static; CF 7 Function Abs ( Value : Double ) : Double; Static;
CF : Methods with this mark are Compact Framework Compatible
 Description Returns the absolute value of the number. Notes The Delphi IDE at the time of writing does not display SByte in the popup list of Abs syntaxes. Static methods are not methods of an object - they are simply class functions or procedures available at any time. Microsoft MSDN Links System System.Math Author links Buy Website Traffic at  Buywebsitetrafficexperts.com  Buy Proxies at Buyproxies.io

 A simple example program Project1; {\$APPTYPE CONSOLE} var   float, bigFloat : Single;   int             : Integer; begin  float    := -1.5;       // Small negative floating point number  bigFloat := -4.56E100;  // Infinite negative floating point number  int      := -7;         // Negative integer   Console.WriteLine('float    = {0}', float.ToString);   Console.WriteLine('bigFloat = {0}', bigFloat.ToString);   Console.WriteLine('int      = {0}', int.ToString);   // Get the absolute values   float    := System.Math.Abs(float);   bigFloat := System.Math.Abs(bigFloat);   int      := System.Math.Abs(int);   Console.WriteLine('float    = {0}', float.ToString);   Console.WriteLine('bigFloat = {0}', bigFloat.ToString);   Console.WriteLine('int      = {0}', int.ToString);   Console.ReadLine; end. float    = -1.5   bigFloat = -Infinity   int      = -7   float    = 1.5   bigFloat = Infinity   int      = 7