Numerics, NaNs, IEEE 754 and C99
Grant Edwards
grante at visi.com
Thu Jun 15 11:08:30 EDT 2006
On 2006-06-15, Nick Maclaren <nmm1 at cus.cam.ac.uk> wrote:
>|> Making Python incompatible with IEEE |> 754 is a bad idea.
>
> No, that is wrong, on many counts.
>
> Firstly, a FAR more common assumption is that integers wrap in twos'
> complement - Python does not do that.
It used to, and I sure wish there was still a way to get that
behavior back. Now I have to do all sorts of bitwise ands that
I didn't use to.
> Secondly, it is NOT incompatible with IEEE 754, which is a
> pure hardware standard. All it does is to trap the exception
> and take appropriate action (as permitted by that standard).
There are two allowed (selectable?) behaviors for 1/0: trap and
Inf.
> Thirdly, virtually no hardware sticks strictly to IEEE 754,
> and no language that I know of has EVER attempted to make it
> the strict basis for its arithmetic model.
All the HW and libraries I've used returned Inf for 1/0.
> Fourthly, I am not proposing to change any hardware,
IMO, having Python's FP results disagree with common HW FP
results would be a pretty bad thing.
> and could even provide a Python option to deliver
> mathematically incorrect results when you want them.
As long as I can get IEEE 754 results, that's cool. I'd prefer
if Python just let the HW do it's thing when possible.
--
Grant Edwards grante Yow! How do I get HOME?
at
visi.com
More information about the Python-list
mailing list