round-to-decimal ( x n -- y )
Factor handbook » The language » Numbers » Mathematical functions » Arithmetic functions

Prev:round ( x -- y )
Next:round-to-step ( x step -- y )


Vocabulary
math.functions

Inputs
xa real
nan integer


Outputs
ya real


Word description
Outputs the number closest to x, rounded to n decimal places.

Notes
The result is not necessarily an integer.

Examples
USING: math.functions prettyprint ; 1.23456 2 round-to-decimal .
1.23

USING: math.functions prettyprint ; 12345.6789 -3 round-to-decimal .
12000.0


Definition