Revision history [back]

There isn't a function for this and oddly we don't recall ever being asked for this before. We will look to add this in a future version.

But you can do this manually as follows:

* Make a number to round
gen1 x = 1.25678

* Define the number of dps as a rounding factor (3dps)
gen1 rnd = 0.001

* Round by formula
gen1 y = int((x/rnd)+0.5) * rnd


Output

 |_print x y
X
1.256780
Y
1.257000


There isn't a Use the INT function for this and oddly we don't recall ever being asked for this before. We will look to add this in a future version. extract the integer part of the decimal e.g.

gen1 y = 3.1
gen1 x = INT(x)


But If you can want to do this manually to specific decimal places do this as follows:

* Make a number to round
gen1 x = 1.25678

* Define the number of dps as a rounding factor (3dps)
gen1 rnd = 0.001

* Round by formula
gen1 y = int((x/rnd)+0.5) INT((x/rnd)+0.5) * rnd


Output

 |_print x y
X
1.256780
Y
1.257000


Use the INT function to extract the integer part of the decimal e.g.

gen1 y x = 3.1
gen1 x y = INT(x)


If you want to do this to specific decimal places do this as follows:

* Make a number to round
gen1 x = 1.25678

* Define the number of dps as a rounding factor (3dps)
gen1 rnd = 0.001

* Round by formula
gen1 y = INT((x/rnd)+0.5) * rnd


Output

 |_print x y
X
1.256780
Y
1.257000


Use the INT function to extract the integer part of the decimal e.g.

gen1 x = 3.1
1.256780
gen1 y = INT(x)


Output

 |_print x y
X
1.256780
Y
1.000000


If you want to do this to specific decimal places you can do this as follows:

* Make a number to round
gen1 x = 1.25678

* Define the number of dps as a rounding factor (3dps)
gen1 rnd = 0.001

* Round by formula
gen1 y = INT((x/rnd)+0.5) * rnd


Output

 |_print x y
X
1.256780
Y
1.257000


Use the INT function to extract the integer part of the decimal e.g.

gen1 x = 1.256780
gen1 y = INT(x)


Output

 |_print x y
X
1.256780
Y
1.000000


If you want To round to do this to a specific number of decimal places you can do this as follows:

* Make a number to round
gen1 x = 1.25678

* Define the number of dps as a rounding factor (3dps)
gen1 rnd = 0.001

* Round by formula
gen1 y = INT((x/rnd)+0.5) * rnd


Output

 |_print x y
X
1.256780
Y
1.257000


Use the There is no direct rounding function however this can be calculated by use of the INT function. The INT function is used to extract the integer part of the decimal e.g.

* Make a number
gen1 x = 1.256780

* Extract Integer part
gen1 y = INT(x)


OutputOutput:

 |_print x y
X
1.256780
Y
1.000000


To round to a specific number of decimal places do as follows:

* Make a number to round
gen1 x = 1.25678

* Define the number of dps as a rounding factor (3dps)
gen1 rnd = 0.001

* Round by formula
to the number of dps in the rounding factor
gen1 y = INT((x/rnd)+0.5) * rnd


OutputOutput:

 |_print x y
X
1.256780
Y
1.257000


To round to 0 dps the rounding factor is 1

gen1 x = 1.55648
gen1 rnd = 1
gen1 y = int((x*rnd)+0.5) / rnd
print y


Output:

 |_print y
Y
2.000000


There is no direct rounding function however this can be calculated by use of the INT function. The INT function is used to extract the integer part of the decimal decimal, but does not round e.g.

* Make a number
gen1 x = 1.256780
1.956780

* Extract Integer part
gen1 y = INT(x)


Output:

 |_print x y
X
1.256780
Y
1.000000


To round to a specific number of decimal places do as follows:

* Make a number to round
gen1 x = 1.25678

* Define the number of dps as a rounding factor (3dps)
gen1 rnd = 0.001

* Round to the number of dps in the rounding factor
gen1 y = INT((x/rnd)+0.5) * rnd


Output:

 |_print x y
X
1.256780
Y
1.257000


To round to 0 dps the rounding factor is 1

gen1 x = 1.55648
gen1 rnd = 1
gen1 y = int((x*rnd)+0.5) / rnd
print y


Output:

 |_print y
Y
2.000000


There is no direct rounding function however this can be calculated by use of the INT function. The INT function is used to extract the integer part of the decimal, but does not round e.g.

* Make a number
gen1 x = 1.956780

* Extract Integer part
gen1 y = INT(x)


Output:

 |_print x y
X
1.256780
1.956780
Y
1.000000


To round to a specific number of decimal places do as follows:

* Make a number to round
gen1 x = 1.25678

* Define the number of dps as a rounding factor (3dps)
gen1 rnd = 0.001

* Round to the number of dps in the rounding factor
gen1 y = INT((x/rnd)+0.5) * rnd


Output:

 |_print x y
X
1.256780
Y
1.257000


To round to 0 dps the rounding factor is 1

gen1 x = 1.55648
gen1 rnd = 1
gen1 y = int((x*rnd)+0.5) / rnd
print y


Output:

 |_print y
Y
2.000000