round-to-decimal ( x n -- y )


Vocabulary
math.extras

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.extras prettyprint ; 1.23456 2 round-to-decimal .
1.23

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


Definition