what is this?

Pettersen, Bjorn S BjornPettersen at fairisaac.com
Mon Nov 3 18:56:07 EST 2003


> From: Hari Pulapaka [mailto:pulapaka at ligo.caltech.edu] 

please don't top-post.

> Hi,
> 
> Most newbies to python, have probably experienced this one time or 
> another. And posted it to the newsgroups, where the Python 
> gurus, will say, No foo thats how floating points are represented, 
> read the tutorial and understand floating point representation, etc...

All you need to remember is that floating point is not exact, and any
attempt at pretending it is _will_ cause other _silent_ problems.

> But call it whatever, 3.4 != 3.3999999999999999 and I feel that 

That's the point, there is no 3.4 <wink>.

> somewhere some change should be made so that the 
> representation is better.

... by that I take it you mean better == less precise? (If you've read
the afore-mentioned manual, I'm genuinely curious why you're still
thinking this is a good idea?) 

> I saw some discussion earlier where, someone provided a function for 
> repr so that the presentation of floating is better and it 
> looked like (to me) that it had a solution for this problem.

Use str() or %f with appropriate modifiers for presentation.

-- bjorn





More information about the Python-list mailing list