[Python-Dev] Caching float(0.0) (original) (raw)
Nick Maclaren nmm1 at cus.cam.ac.uk
Wed Oct 4 14:12:06 CEST 2006
- Previous message: [Python-Dev] Caching float(0.0)
- Next message: [Python-Dev] PEP 315 - do while
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, Oct 04, 2006 at 12:42:04AM -0400, Tim Peters wrote:
> If C90 doesn't distinguish -0.0 and +0.0, how can Python? > Can you give a simple example where the difference between the two > is apparent to the Python programmer? Perhaps surprsingly, many (well, comparatively many, compared to none ....) people have noticed that the platform atan2 cares a lot:
Once upon a time, floating-point was used as an approximation to mathematical real numbers, and anything which was mathematically undefined in real arithmetic was regarded as an error in floating- point. This allowed a reasonable amount of numeric validation, because the main remaining discrepancy was that floating-point has only limited precision and range.
Most of the numerical experts that I know of still favour that approach, and it is the one standardised by the ISO LIA-1, LIA-2 and LIA-3 standards for floating-point arithmetic.
atan2(0.0,0.0) should be an error.
But C99 differs. While words do not fail me, they are inappropriate for this mailing list :-(
Regards, Nick Maclaren, University of Cambridge Computing Service, New Museums Site, Pembroke Street, Cambridge CB2 3QH, England. Email: nmm1 at cam.ac.uk Tel.: +44 1223 334761 Fax: +44 1223 334679
- Previous message: [Python-Dev] Caching float(0.0)
- Next message: [Python-Dev] PEP 315 - do while
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]