Russell wrote:

> If you like one-liners, how about:
>
> >> round: func [n][print to-integer n + either n < 0 [-.5][.5]]
>
> This prints integer closest to n.
>

I am sorry, but this is wrong, too: round -0.5 should be 0 and not -1. Try
to compare with these:

floor: func [x [number!] /local y] [(y: to-integer x) - to-integer x < y]
round: func [x [number!]] [floor x + 0.5]

or, as a one-liner:

round: func [x [number!] /local y z] [(y: to-integer z: (x + 0.5)) -
to-integer z < y]

Ladislav

Reply via email to