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;...") |
ClomosyAdmin (talk | contribs) No edit summary |
||
| (4 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
<div class="alert alert-ligth border border-3 border-primary-subtle rounded-5 p-4 shadow-sm" role="alert"> | |||
function Round(X: Real): Int64; | |||
</div> | |||
It is used to round decimal numbers to the nearest whole number. If the decimal part is greater than 0.5, it rounds up; if it is less than 0.5, it rounds down. If the given number is exactly halfway (0.5) between two numbers, the result is always the even number.<br> | |||
12.4 rounds to 12 | 12.4 rounds to 12<br> | ||
12.5 rounds to 12 // Round down to even | 12.5 rounds to 12 // Round down to even<br> | ||
12.6 rounds to 13 | 12.6 rounds to 13<br> | ||
13.4 rounds to 13<br> | |||
13.4 rounds to 13 | 13.5 rounds to 14 // Round up to even<br> | ||
13.5 rounds to 14 // Round up to even | 13.6 rounds to 14<br> | ||
13.6 rounds to 14 | |||
<b>Example</b><br> | |||
'''Output: | <pre> | ||
var | |||
numberFloat : Float; | |||
{ | |||
numberFloat = 15.50; | |||
ShowMessage('Round('+FloatToStr(numberFloat)+') = '+FloatToStr(Round(numberFloat))); | |||
} | |||
</pre> | |||
<b>Output:</b><br> | |||
<div class="alert alert-success" role="alert" data-bs-theme="light"> | |||
Round(15,5) = 16 | |||
</div> | |||
<h2> See Also </h2> | |||
* [[System_Library#Math_Functions | Math Functions]] | |||
{{#seo:|title=Using Round in Clomosy - Clomosy Docs}} | |||
{{#seo:|description=Utilize Clomosy’s Round function to round numbers efficiently in your mobile apps, ensuring accurate and optimized calculations.}} | |||
Latest revision as of 13:19, 24 December 2024
function Round(X: Real): Int64;
It is used to round decimal numbers to the nearest whole number. If the decimal part is greater than 0.5, it rounds up; if it is less than 0.5, it rounds down. If the given number is exactly halfway (0.5) between two numbers, the result is always the 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
var
numberFloat : Float;
{
numberFloat = 15.50;
ShowMessage('Round('+FloatToStr(numberFloat)+') = '+FloatToStr(Round(numberFloat)));
}
Output:
Round(15,5) = 16