> I too prefer rounding of negative numbers towards plus infinity; to me, zero
> should be merely a reference point, not a reflection point..  But to-integer
> (n + .5) doesn't work the way I thought it should between -1.499999 and -.5
> it yields 0 as it does from 0 to +.499999. 

Oh, I'm really brainless sometimes. ;-) 

 In other words, the range over
> which it yields 0 is approx 2 there, where elsewhere the range is 1.  Round
> can't be used to create a step function where the "treads" are all 1 in
> "width".
> 
> The function below nicely rounds negative numbers towards minus infinity the
> way engineers prefer, so it, too, results in a tread width of 2 around zero.
> 
> I've worked around this in several applications (e.g., locating a cursor in
> a square of a game board) by first adding an arbitrary integer constant to
> make all practical numbers positive, then rounding, then subtracting the
> constant.

Yes, this is good solution.

round: func [a][
        either negative? a [
                b: to-integer a - 10
                b + round a - b
        ][to-integer a + 0.5]
]

Regards,
Jan

--
Jan Strejcek
[EMAIL PROTECTED]

Reply via email to