This page has been updated to the public function directory under the System Unit.
// Absolute value: absvar D: real; V: variant; begin D: = ABS (-1.2); showmessage (floattostr (d); {1.2} V: = '-100'; showmessage (V); {-100; V is a variant type without conversion} V: = ABS (V); showmessage (V); {100; if the variable is indeed a number, the variant type can also take the absolute value} end;
// Return INTEGER: trunc, round, intvar I: integer; D: real; begin I: = trunc (1234.5678); {truncation} showmessage (inttostr (I )); {1234} I: = round (1234.5678); {rounding} showmessage (inttostr (I); {1235} {BOTH int and trunc are rounded to 0, but the int returned is not an integer type} D: = int (-1234.5678); showmessage (floattostr (d); {-1234} end;
// Square: sqr var D: real; begin D: = sqr (6); showmessage (floattostr (d); {36} end;
// Square root: SQRT var D: real; begin D: = SQRT (81); showmessage (floattostr (d); {9} end;
// Judge whether an integer is an odd number: oddvar I: integer; B: Boolean; begin I: = 11; B: = odd (I ); {returns an odd number} showmessage (booltostr (B); {true} I: = 12; B: = odd (I); showmessage (booltostr (B )); {false} end;