Syntax
set aFloat = aFloat.round(base)
Semantics

round() rounds float to a given base. E.g. if you want to remove the fraction then base is 1.0. The common method is implemented:

  • Decide which is the last digit to keep.
  • Increase it by 1, if the next digit is 5 or more (this is called rounding up).
  • Leave it the same, if the next digit is 4 or less (this is called rounding down).
    See also Rounding on Wikipedia.
SubstitutablesaFloat Can be any variable or object attribute having the type Float
baseIs of type Float and encodes the base to be rounded to. For examples, see the table below.
Examples
set aFloat1 = aFloat1.round(2); 
set aFloat2 = aFloat3.round(aFloat4);

Table: Base Examples for the round() Operation

Rounding Result

aFloat

Base

33.11.0
331.0
33.4991.0
43.9991.0
43.51.0
43.5011.0
-3-3.11.0
-3-31.0
-3-3.4991.0
-4-3.9991.0
-4-3.51.0
-4-3.5011.0
999999999999999999999999999.499999999999999999999999999999.4990.001
3.4993.4990.001
3.53.4990.01
3.53.4990.1
3.53.4990.5
33.4991.0
03.49910.0
-3.499-3.4990.001
-3.5-3.4990.01
-3.5-3.4990.1
-3.5-3.4990.5
-3-3.4991.0
0-3.49910.0