From Clomosy Docs
(Created page with " function Round(const Number Extended):Int64; The Round function rounds a floating point Number to an Integer value. The rounding uses Bankers rules, where an exact half value causes a rounding to an even number: 12.4 rounds to 12 12.5 rounds to 12 // Round down to even 12.6 rounds to 13 13.4 rounds to 13 13.5 rounds to 14 // Round up to even 13.6 rounds to 14 '''Example:'''<br> '''var''' numberFloat : Float;<br> '''begin'''<br> numberFloat := 15.50;...") |
No edit summary |
||
| Line 12: | Line 12: | ||
'''Example:'''<br> | '''Example:'''<br> | ||
:'''Base Syntax''' | |||
var | |||
numberFloat : Float; | |||
begin | |||
numberFloat := 15.50; | |||
ShowMessage('Round('+FloatToStr(numberFloat)+') = '+FloatToStr('''Round'''(numberFloat))); | |||
end; | |||
:'''TRObject Syntax''' | |||
var | |||
numberFloat : Float; | |||
{ | |||
numberFloat = 15.50; | |||
ShowMessage('Round('+FloatToStr(numberFloat)+') = '+FloatToStr('''Round'''(numberFloat))); | |||
} | |||
'''Output:'''<br> | '''Output:'''<br> | ||
Round(15,5) = 16 | Round(15,5) = 16 | ||
Revision as of 13:34, 13 February 2024
function Round(const Number Extended):Int64;
The Round function rounds a floating point Number to an Integer value. The rounding uses Bankers rules, where an exact half value causes a rounding to an even number:
12.4 rounds to 12 12.5 rounds to 12 // Round down to even 12.6 rounds to 13
13.4 rounds to 13 13.5 rounds to 14 // Round up to even 13.6 rounds to 14
Example:
- Base Syntax
var
numberFloat : Float;
begin
numberFloat := 15.50;
ShowMessage('Round('+FloatToStr(numberFloat)+') = '+FloatToStr(Round(numberFloat)));
end;
- TRObject Syntax
var
numberFloat : Float;
{
numberFloat = 15.50;
ShowMessage('Round('+FloatToStr(numberFloat)+') = '+FloatToStr(Round(numberFloat)));
}
Output:
Round(15,5) = 16