Re: How to coerce a real to an integer in X?
Re: How to coerce a real to an integer in X?
- Subject: Re: How to coerce a real to an integer in X?
- From: email@hidden (Michael Sullivan)
- Date: Fri, 1 Feb 2002 12:07:02 -0500
- Organization: Society for the Incurably Pompous
>
On Thu, 31 Jan 2002 22:18:58 -0500, "Bob.Kalbaugh"
>
<email@hidden> asked,
>
>
> And what's up with this?
>
>
>
> (3.5)
>
> integer result
>
> --> 4
>
>
>
> (4.5)
>
> integer result
>
> --> 4 (???)
>
>
>
> (5.5)
>
> integer result
>
> --> 6
>
>
>
> (6.5)
>
> integer result
>
> --> 6 (???)
>
This is the IEEE Floating Point standard's rounding rules, which are to
>
round a value that is exactly half way between two points so that the
>
resulting least significant digit is even. This way, half the rounding is
>
up, and half the rounding is down, and you have no bias to the error.
>
IEEE Floating Point is how the PowerPC chip is hardwired.
Except that's not true, unless you don't count x.0
{0,1,2,3,4} is 5 possible digits
{5,6,7,8,9} is 5 possible digits.
The only way I can make sense of it is by assuming that any digits
beyond the result were *rounded* rather than truncated -- so that 3.5
could be the result of a calculation that yielded 3.45, or one that
yielded 3.55. You don't know which side it was on, so it makes sense to
use some arbitrary known 50% method to break up 5s.
This makes a lot of sense when interpreting analog data (such as
measurements) where a scale that reads tenths will probably read 3.5 for
an actual weight of 3.45 or 3.46.
But i thought floating point digital representations usually truncated
rather than rounding when reaching the end of their precision, so the
traditional method should be used.
Bah. Engineers.
Is there an apologia for this rounding method with FP data in the house?
Am I misinformed? Do many standard chips round lost digits in FP
arithmetic?
Michael
--
Michael Sullivan
Business Card Express of CT Thermographers to the Trade
Cheshire, CT email@hidden