From Clomosy Docs
No edit summary |
No edit summary |
||
| Line 8: | Line 8: | ||
Let's say you have a variable i. The type of this variable is assigned as integer. The value of this variable can be given an integer value. Here we have given a negative value. Finally, abs function was used to get the absolute value. <br> | Let's say you have a variable i. The type of this variable is assigned as integer. The value of this variable can be given an integer value. Here we have given a negative value. Finally, abs function was used to get the absolute value. <br> | ||
:'''Base Syntax''' | |||
var | var | ||
i : Integer; | i : Integer; | ||
| Line 19: | Line 20: | ||
end; | end; | ||
:'''TRObject Syntax''' | |||
var | |||
i : Integer; | |||
{ | |||
i = -1235; | |||
ShowMessage('Before: '+ IntToStr(i)); | |||
//The absolute value of i is taken and put back to i. | |||
i = Abs(i); | |||
ShowMessage('After: '+IntToStr(i)); | |||
} | |||
Revision as of 07:12, 6 February 2024
function Abs(Number Numeric type):Numeric type;
Returns the absolute value of an integer.
Syntax:
value := Abs(value);
Example:
Let's say you have a variable i. The type of this variable is assigned as integer. The value of this variable can be given an integer value. Here we have given a negative value. Finally, abs function was used to get the absolute value.
- Base Syntax
var
i : Integer;
begin
i := -1235;
ShowMessage('Before: '+ IntToStr(i));
//The absolute value of i is taken and put back to i.
i:= Abs(i);
ShowMessage('After: '+IntToStr(i));
end;
- TRObject Syntax
var
i : Integer;
{
i = -1235;
ShowMessage('Before: '+ IntToStr(i));
//The absolute value of i is taken and put back to i.
i = Abs(i);
ShowMessage('After: '+IntToStr(i));
}