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

Replacing the word 'mantissa' with 'significand' when appropriate in Chapel documentation #19282

Open
damianmoz opened this issue Feb 19, 2022 · 6 comments

Comments

@damianmoz
Copy link

damianmoz commented Feb 19, 2022

In

https://chapel-lang.org/docs/language/spec/conversions.html

The word mantissa is used where it really means the IEEE 754 concept of significand. There is an implied function mant(t) which is trying to return the number of digits in this incorrectly named mantissa.

Does anybody have any suggestions on rewording this to be more IEEE 754 compliant before I make my take on it?

It is also called mantissa in NPBRrandom, which again is the wrong term.

@damianmoz
Copy link
Author

damianmoz commented Feb 19, 2022

There is no concept of a mantissa in a real(w) floating point number these days, certainly not in those defined by the IEEE 754 standard that Chapel supports and pretty well all of today's CPUs implement (mostly fully). Specifically:

... Replace every occurrence of _mant(w)+1+ in the table with prec(w), and of mant(w) by prec(w)-1 where w is t or t/2 in several places.

The function prec(w) is the number of binary digits in the significand of the w-bit floating-point type including the implicit hidden bit which is always 1 and is not stored in the bit pattern. This is 24 for a real(32) and 53 with real(64). If Chapel ever implements the 80-bit IEEE 754 extended point type, that definition will need to change. Hopefully, 128-bit floating point comes along before that ever becomes a necessary and saves humanity.

@bradcray
Copy link
Member

I'm almost certainly responsible for the occurrence in NPBRandom.chpl, though in my defense, the context for that occurrence is a direct quote from the NPB code itself. This seems like one of those classic cases of "preserve the quote because that's the quote said" vs. "correct the quote itself". A hybrid solution would be to follow up the quote with a statement of clarification.

@bradcray
Copy link
Member

The developer who introduced "mantissa" into the spec no longer works for us, so I can't tag them here as intended. @mppf, you seem to have used the term within the compiler recently and less recently. Any thoughts here?

@damianmoz
Copy link
Author

I often fall back on 'mantissa' when I really want to say signed significand. Even C's library is messy.

The significand(x) function returns the mantissa of x scaled to the range [1,2).

This is the reverse. Here, the routine is returning the signed significand, not the actual significand which has magnitude only.

The word mantissa is used way too imprecisely and always needs to be qualified.

@mppf
Copy link
Member

mppf commented Feb 22, 2022

@damianmoz - I often use Wikipedia to answer the question of what people mean when using a particular term. https://en.wikipedia.org/wiki/Significand#Terminology acknowledges that it is common for computer scientists to use the term "mantissa" but also lists some experts saying we should really be using "significand" and includes a justification for why significand is a better term. Which is pretty much what is happening right here right now :)

While I am open to using significand instead, it seems that mantissa has enough history in floating point to be clear enough. In particular, my introductory numerical analysis book ("Scientific Computing: an Introductory Survey") indicates that mantissa and significand are synonyms and then goes on to use the term mantissa from that point. I think my main problem with significand is that my spell checker doesn't think it's a word. (Obviously that is easy to fix for me personally - but is it perhaps indicating that it is not actually a common term for it?)

Anyway, if we want to rely on IEEE 754 to define the floating point operations, we should be using consistent terminology with it. So, maybe the spec should say something like "significand, sometimes called mantissa" so that people could find it if "mantissa" was the term familiar to them.

@damianmoz
Copy link
Author

I like your wise idea (with spelling corrected) of

... the spec should say something like "significand, sometimes called mantissa"

If such a flash of wisdom had hit my brain at the time, I would have suggested it myself. But sadly not.

Mantissa has a less strict definition. Significand as the IEEE 754 standard has a very strict definition, what the Wikipedia article calls the normalized significand, and is unsigned. Mind you, C's library routine significand(x) returns the 'signed significand` so it is all a bit moot. Some people say the mantissa is between 0.5 and 1.0 which is what the C floating point model back in the 1980s said.

Either way, if you want to say that mantissa are the same, the formula is still out by 1. So my point holds. If you are saying that the mantissa is the significand without the leading hidden bit, then the existing formula is correct.

I updated my spelling dictionary ages ago to include significand. It has been around in the standard for the lifetime of at least many using Chapel, and if you note that George Forsythe and Cleve Moler used it in 1967 (long before I used a computer), it has been around for the lifetime of most people using Chapel..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants