Re: [Python-ideas] Python-ideas Digest, Vol 103, Issue 2
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
On Mon, Jun 1, 2015, at 15:13, u8y7541 The Awesome Person wrote:
Floats internally use numerator and denominator (float.as_integer_ratio().)
The fact that this method exists is not actually evidence that this form is used internally. This is a utility method, provided, I suspect, for the use of the fractions.Fraction constructor (which class does use a numerator and denominator).
participants (2)
-
random832@fastmail.us
-
u8y7541 The Awesome Person