Re: Rounding double
jacob navia said:
So the original problem is insoluble, and another approach must be found,
such as the approach I suggested in my very first reply. Pretending that
0.3 *is* representable in a double (without switching to a radix that
makes other numbers unrepresentable ) is silly.
<snip>
>>
>Indeed, but the result will still be out.
>>
>
That is floating point! It is intrinsic to the nature of floating
point,
Quite so. This is indeed the whole point.
<snip>
--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
jacob navia said:
Richard Heathfield wrote:
>
We all know that Heathfield. O.3 is not representable,
so what?
>>
>But rounding is an operation that yields an exact result. 0.33, rounded
>to one decimal place, is *precisely* 0.3, not 0.2999999999999 98 or
>0.300000000000 001 (no, I didn't count the 9s and 0s - I just held the
>key down!). If the result is not exact, it isn't a rounding. It's merely
>an approximation to a rounding.
>>
>>
>Oh, it can be done all right - it's just that it can't be done using
>floating point. More precisely, you can't store 0.33 rounded to one
>decimal place in a floating point number (unless you use a radix that
>makes it possible, in which case there are other numbers you can't
>store).
>>
>But rounding is an operation that yields an exact result. 0.33, rounded
>to one decimal place, is *precisely* 0.3, not 0.2999999999999 98 or
>0.300000000000 001 (no, I didn't count the 9s and 0s - I just held the
>key down!). If the result is not exact, it isn't a rounding. It's merely
>an approximation to a rounding.
>>
>>because of the nature of
>>floating point, but will be billions of times more accurate than
>>doing no rounding because 'it can't be done'.
>>floating point, but will be billions of times more accurate than
>>doing no rounding because 'it can't be done'.
>Oh, it can be done all right - it's just that it can't be done using
>floating point. More precisely, you can't store 0.33 rounded to one
>decimal place in a floating point number (unless you use a radix that
>makes it possible, in which case there are other numbers you can't
>store).
>>
We all know that Heathfield. O.3 is not representable,
so what?
such as the approach I suggested in my very first reply. Pretending that
0.3 *is* representable in a double (without switching to a radix that
makes other numbers unrepresentable ) is silly.
<snip>
>>The result, being stored in floating point binary,
>>may be out by a billionth of a micron or so. So what? My pencil mark
>>on the stick will not be that accurate.
>>may be out by a billionth of a micron or so. So what? My pencil mark
>>on the stick will not be that accurate.
>Indeed, but the result will still be out.
>>
That is floating point! It is intrinsic to the nature of floating
point,
<snip>
--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Comment