rounding up with < .5 ?

Yates, Glen JAMES.G.YATES at saic.com
Thu Mar 14 18:17:01 EST 2002


Yes, you are right, my solution fails when you start with an integer.
In answering this question I was thinking back to a way of rounding by
adding .5 then trunicating.

But, if MC/Rev rounded properly, it would work for your example, i.e.

4.5 should round to 4

however it would still fail for odd numbers, i. e.

5.5 should round to 6

-Glen

> Not sure just adding 0.5 would give the required result (if I 
> understand the
> problem correctly).
> ie
>  tresult=round(x+0.5)
> 
> With three examples for x say 3.9, 4.0, and 4.1
> tresult returns 4, 5 and 5
> 
> As the middle number is an integer then I'd guess it doesn't 
> need rounding
> up, so the required results should be 4,4,5. Unless I missed 
> something....
> 
> Please see my other post relating to TRUNC.
> 
> Regards
> 
> Gary Rathbone
> http://lists.runrev.com/mailman/listinfo/use-revolution
> 



More information about the use-livecode mailing list