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
|
|
|
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.
| Show full unit code | float = -1.5
bigFloat = -Infinity
int = -7
float = 1.5
bigFloat = Infinity
int = 7
|
|
|
|