round-to-step ( x step -- y ) (original) (raw)
Inputs
x | a real |
---|---|
step | a real |
Outputs
y | a real |
---|
Word description
Outputs the number closest to x, rounded to a multiple of step.
Notes
The result is not necessarily an integer.
Examples
USING: math.functions prettyprint ; 1.23456 0.25 round-to-step .
1.25
USING: math.functions prettyprint ; 12345.6789 100 round-to-step .
12300.0
Definition
: round-to-step ( x step -- y )
[ [ / round ] [ * ] bi ] unless-zero ;