From Clomosy Docs

No edit summary
No edit summary
 
(2 intermediate revisions by 2 users not shown)
Line 13: Line 13:


<b>Example</b><br>
<b>Example</b><br>
<b>TRObject Syntax</b><br>
 
<pre>
<pre>
  var
  var
Line 24: Line 24:
   
   
  }
  }
</pre>
<b>Base Syntax</b><br>
<pre>
var
  numberFloat : Float;
begin
  numberFloat := 15.50; 
  ShowMessage('Round('+FloatToStr(numberFloat)+') = '+FloatToStr(Round(numberFloat)));
end;
</pre>
</pre>


Line 45: Line 33:
<h2> See Also </h2>
<h2> See Also </h2>
* [[System_Library#Math_Functions | Math Functions]]
* [[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

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:

See Also