Precision issue

Ben Finney bignose-hates-spam at and-benfinney-does-too.id.au
Fri Oct 10 08:48:22 EDT 2003


On Fri, 10 Oct 2003 10:36:16 +0000 (UTC), Duncan Booth wrote:
> I know this is an FAQ, but the one thing I've never seen explained
> satisfactorily is why repr(3.4) has to be '3.3999999999999999' rather
> than '3.4'?

Because '3.4' is what str(3.4) returns.  If repr(3.4) lies about the
value stored, what function will you leave us to discover the actual
value?

The str() function is for getting the working output of the value.  The
repr() function is for discovering, as precisely as possible, the actual
value.

-- 
 \      "I know the guy who writes all those bumper stickers. He hates |
  `\                                      New York."  -- Steven Wright |
_o__)                                                                  |
Ben Finney <http://bignose.squidly.org/>




More information about the Python-list mailing list