[comp.databases] Clipper round

cnas09@vaxa.strath.ac.uk (06/27/91)

	Can anyone explain the (to me) rather peculiar behaviour of the round()
routine in Clipper 5? If you do something like round(37*1.175, 2) then round()
correctly reports 43.48 but using round(39*1.175, 2) gives 45.82 when it should
have rounded it up to 45.83! 

	Am I missing something here?


Aaron Ferguson
EE Dept
University of Strathclyde

tleylan@pegasus.com (Tom Leylan) (06/29/91)

In article <1991Jun27.095337.11969@vaxa.strath.ac.uk> cnas09@vaxa.strath.ac.uk writes:
>
>	Can anyone explain the (to me) rather peculiar behaviour of the round()
>routine in Clipper 5? If you do something like round(37*1.175, 2) then round()
>correctly reports 43.48 but using round(39*1.175, 2) gives 45.82 when it should
>have rounded it up to 45.83! 
>
Aaron,

I can't give you _the_ reason but I believe that it is somewhat due to the
behavior of the MSC alternate floating point library that Clipper uses.

It would seem that the binary representation of 39 * 1.175 isn't 45.825 but
is more like 45.8249999999 while the output is 45.825.

I think it's annoying but I don't believe that you'll find that the ROUND()
function is "wrong" but rather that the number it is being asked to round
isn't the one that we see.

I'll see if I can track down a more exact answer.

tom

tleylan@pegasus.com (Tom Leylan) (06/29/91)

In article <1991Jun27.095337.11969@vaxa.strath.ac.uk> cnas09@vaxa.strath.ac.uk writes:
>
>	Can anyone explain the (to me) rather peculiar behaviour of the round()
>routine in Clipper 5? If you do something like round(37*1.175, 2) then round()
>correctly reports 43.48 but using round(39*1.175, 2) gives 45.82 when it should
>have rounded it up to 45.83! 
>
Aaron,

As a followup to my own message... I just tried the two examples you gave on
my copy of Clipper 5.01 and I get the correct answers for both of them.

Are you using the original version of 5.0 ?  That might have something to do
with it.

tom