Floats internally use numerator and denominator (float.as_integer_ratio().) It makes no sense to have sign and mantissa while displaying numerator and denominator. Perhaps a redo of the class? I believe fractions should be the standard, and just keep the ieee754 floats as a side option.

On Sun, May 31, 2015 at 7:37 PM, <python-ideas-request@python.org> wrote:
Send Python-ideas mailing list submissions to
        python-ideas@python.org

To subscribe or unsubscribe via the World Wide Web, visit
        https://mail.python.org/mailman/listinfo/python-ideas
or, via email, send a message with subject or body 'help' to
        python-ideas-request@python.org

You can reach the person managing the list at
        python-ideas-owner@python.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Python-ideas digest..."


Today's Topics:

   1. Python Float Update (u8y7541 The Awesome Person)
   2. Re: Python Float Update (Nathaniel Smith)


----------------------------------------------------------------------

Message: 1
Date: Sun, 31 May 2015 19:25:46 -0700
From: u8y7541 The Awesome Person <surya.subbarao1@gmail.com>
To: python-ideas@python.org
Subject: [Python-ideas] Python Float Update
Message-ID:
        <CA+o1fZONRG_dZzct_VZwcUvtwD-5rJ6zOFxNR34jWFrpUXiw9Q@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Dear Python Developers:

I will be presenting a modification to the float class, which will improve
its speed and accuracy (reduce floating point errors). This is applicable
because Python uses a numerator and denominator rather than a sign and
mantissa to represent floats.

First, I propose that a float's integer ratio should be accurate. For
example, (1 / 3).as_integer_ratio() should return (1, 3). Instead, it
returns(6004799503160661, 18014398509481984).

Second of all, even though 1 * 3 = 3 (last example), 6004799503160661 * 3
does not equal 18014398509481984. Instead, it equals 1801439850948198**3**,
one less than the value in the ratio. This means the ratio is inaccurate,
as well as completely not simplified.


[image: Inline image 1]


Even if the value displayed for a float is a rounded value, the internal
numerator and denominator should divide to equal to completely accurate
value.

Thanks for considering this improvement!

Sincerely,
u8y7541
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150531/019029a6/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pythonfloats.PNG
Type: image/png
Size: 16278 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150531/019029a6/attachment-0001.png>

------------------------------

Message: 2
Date: Sun, 31 May 2015 19:37:14 -0700
From: Nathaniel Smith <njs@pobox.com>
To: u8y7541 The Awesome Person <surya.subbarao1@gmail.com>
Cc: python-ideas@python.org
Subject: Re: [Python-ideas] Python Float Update
Message-ID:
        <CAPJVwBnJqygpOktfD+qRy0J_UZE9MD0hkR+R2=wE1PWDSrquzg@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

On May 31, 2015 7:26 PM, "u8y7541 The Awesome Person" <
surya.subbarao1@gmail.com> wrote:
>
> Dear Python Developers:
>
> I will be presenting a modification to the float class, which will
improve its speed and accuracy (reduce floating point errors). This is
applicable because Python uses a numerator and denominator rather than a
sign and mantissa to represent floats.

Python's floats are in fact ieee754 floats, using sign/mantissa/exponent,
as provided by all popular CPU floating point hardware. This is why you're
getting the results you see -- 1/3 cannot be exactly represented as a
float, so it gets rounded to the closest representable float, and then
as_integer_ratio shows you an exact representation of this rounded value.
It sounds like you're instead looking for an exact fraction representation,
which in python is available in the standard "fractions" module:

https://docs.python.org/3.5/library/fractions.html

-n
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150531/d3147de9/attachment.html>

------------------------------

Subject: Digest Footer

_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas


------------------------------

End of Python-ideas Digest, Vol 103, Issue 2
********************************************



--
-Surya Subbarao