Name
Abs Function
Syntax
function Abs(Number:Numeric type):Numeric type;
Description
The Abs function computes and returns an absolute
value. The function is built into the compiler.
Return Value
If the number has an integer type,
Abschecks whether the value is negative and if so, negates it. The return type isIntegerorInt64, depending on the type of the argument.For a floating-point number,
Absclears the sign bit without altering any other bit. In other words, negative zero and negative infinity become positive zero and positive infinity. Even if the value is NaN, the result is the original number with a zero for the sign bit.
|
Argument |
Return |
|
-infinity |
+infinity |
|
< 0 |
-number |
|
-0.0 |
+0.0 |
|
+0.0 |
+0.0 |
|
> 0.0 |
number |
|
+infinity |
+infinity |
|
quiet NaN |
original value with sign bit set to zero |
|
signaling NaN |
original value with sign bit set to zero |
If the argument is a
Variant, Delphi converts it to a floating-point number and then takes the absolute value, returning a floating-point result (even if theVariantvalue is an integer).
See Also
| Double Type, Extended Type, Int64 Type, Integer Type, Single Type |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access