A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-January/059861.html below:

[Python-Dev] str with base

[Python-Dev] str with base [Python-Dev] str with baseAdam Olsen rhamph at gmail.com
Wed Jan 18 03:17:27 CET 2006
On 1/17/06, Bob Ippolito <bob at redivi.com> wrote:
>
> On Jan 17, 2006, at 3:38 PM, Adam Olsen wrote:
>
> > I dream of a day when str(3.25, base=2) == '11.01'.  That is the
> > number a float really represents.  It would be so much easier to
> > understand why floats behave the way they do if it were possible to
> > print them in binary.
>
> Actually if you wanted something that closely represents what a
> floating point number is then you would want to see this::
>
>         >>> str(3.25, base=2)
>         '1.101e1'
>         >>> str(0.25, base=2)
>         '1.0e-10'
>
> Printing the bits without an exponent is nearly as misleading as
> printing them in decimal.

I disagree.  The exponent is involved in rounding to fit in compact
storage but once that is complete the value can be represented exactly
without it.

--
Adam Olsen, aka Rhamphoryncus
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4