Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Floating point tutorial: "today (November 2000)" #104479

Closed
pochmann opened this issue May 14, 2023 · 11 comments
Closed

Floating point tutorial: "today (November 2000)" #104479

pochmann opened this issue May 14, 2023 · 11 comments
Assignees
Labels
docs Documentation in the Doc dir easy

Comments

@pochmann
Copy link
Contributor

pochmann commented May 14, 2023

Documentation

It says:

Almost all machines today (November 2000) use IEEE-754 floating point arithmetic, and almost all platforms map Python floats to IEEE-754 “double precision”. 754 doubles contain 53 bits of precision, [...]

That feels really weird, computer documentation written 22.5 years ago. I don't know what to think of that, whether that can be trusted today. I suggest to update that.

I also suggest to not start the next sentence with "754 doubles" but with "IEEE-754 doubles", both for style (don't start a sentence with a digit) and because it reads like a number of doubles instead of the kind of doubles (i.e., like "3 apples").

@mdickinson

Linked PRs

@pochmann pochmann added the docs Documentation in the Doc dir label May 14, 2023
@sunmy2019 sunmy2019 added the easy label May 14, 2023
@mdickinson
Copy link
Member

mdickinson commented May 14, 2023

Agreed that this could use an update. The statement is still true, of course. (If anything, it's even more true today than when it was written, and is likely to remain so for some time, despite the excitement over things like bfloats and posits.)

How about we just drop the explicit date and the "today"?

Almost all machines use IEEE 754 floating-point arithmetic, [...]

It would also be good to mention the "binary64" format explicitly, since that's the particular IEEE 754 interchange format that we care about and IEEE 754 defines various other formats these days (including decimal formats). The standard doesn't use the term "double precision". (I think it's fine to keep it in quotes, since it's a common way to refer to the binary64 format, but it would be good to say "binary64" as well somewhere to avoid ambiguity.)

And a super-nitpick: "IEEE 754" should not be hyphenated.

@rhettinger
Copy link
Contributor

Perhaps instead of "today", use "most machines since 2000" or somesuch. This might convey that this isn't a new state of affairs.

@David-Ademola
Copy link

Since November 2000, IEEE-754 floating point arithmetic is utilized by nearly all machines, and Python floats are predominantly mapped to the IEEE-754 "double precision" format across various platforms. Specifically, 754 doubles are capable of retaining 53 bits of precision, thereby facilitating high-precision calculations.

I feel the above is a better way of writing it. And if you think improvements can be made to it, please do.

@ericvsmith
Copy link
Member

I don't think "November 2000" adds anything. The statement was just as true a year before, or a year after. I guess we could drop the month, but it still seems oddly specific to pick 2000 as the time the statement became true.

@David-Ademola
Copy link

Ah, I see, that's true, the month isn't needed.
And according to Wikipedia, the first standard for floating-point arithmetic, IEEE 754-1985, was published in 1985.
So would it be more accurate to say, "Since 1985......."

@ericvsmith
Copy link
Member

Only if 1985 is when the statement "IEEE-754 floating point arithmetic is utilized by nearly all machines" became true. I don't think we need to qualify it with a date. It's true now, so let's just leave it at that: no month or year.

@David-Ademola
Copy link

Agreed. 🤝🏾

@hugovk
Copy link
Member

hugovk commented May 15, 2023

So something like this?

diff --git a/Doc/tutorial/floatingpoint.rst b/Doc/tutorial/floatingpoint.rst
index 306b1eba3c..17434486d4 100644
--- a/Doc/tutorial/floatingpoint.rst
+++ b/Doc/tutorial/floatingpoint.rst
@@ -269,8 +269,8 @@ This is the chief reason why Python (or Perl, C, C++, Java, Fortran, and many
 others) often won't display the exact decimal number you expect.
 
 Why is that?  1/10 is not exactly representable as a binary fraction. Almost all
-machines today (November 2000) use IEEE-754 floating point arithmetic, and
-almost all platforms map Python floats to IEEE-754 "double precision".  754
+machines use IEEE 754 floating-point arithmetic, and
+almost all platforms map Python floats to IEEE 754 "double precision".  IEEE 754
 doubles contain 53 bits of precision, so on input the computer strives to
 convert 0.1 to the closest fraction it can of the form *J*/2**\ *N* where *J* is
 an integer containing exactly 53 bits.  Rewriting ::

Also nitpicks "floating point arithmetic" -> "floating-point arithmetic".

This would be a good PR for a new contributor. @David-Ademola, would you like to give it a go?

@pochmann
Copy link
Contributor Author

I agree with Raymond that it's useful to convey that this is "stable", i.e., has been the case for a long time. I agree with Eric that "since 2000" is oddly specific and doubtful (unless there was a sudden vast change that year). My proposal, also fixing the other issues:

Current:

Almost all machines today (November 2000) use IEEE-754 floating point arithmetic, and almost all platforms map Python floats to IEEE-754 “double precision”. 754 doubles contain 53 bits of precision, so [...]

Proposal:

Almost all machines use IEEE 754 floating point arithmetic, and almost all platforms map Python floats to IEEE 754 “double precision” binary64 (and this has been the case for decades). IEEE 754 binary64 contains 53 bits of precision, so [...]

@David-Ademola
Copy link

Sure @hugovk

@mdickinson mdickinson self-assigned this May 20, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this issue May 26, 2023
…ythonGH-104681)

(cherry picked from commit 2cf04e4)

Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
hauntsaninja pushed a commit to hauntsaninja/cpython that referenced this issue May 26, 2023
…ence (pythonGH-104681).

(cherry picked from commit 2cf04e4)

Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
hauntsaninja added a commit that referenced this issue May 26, 2023
…H-104681) (#104961)

(cherry picked from commit 2cf04e4)

Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
hauntsaninja pushed a commit that referenced this issue May 26, 2023
…H-104681) (#104960)

(cherry picked from commit 2cf04e4)

Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
@hauntsaninja
Copy link
Contributor

Thanks all!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir easy
Projects
None yet
Development

No branches or pull requests

8 participants