this post was submitted on 12 Mar 2024
129 points (94.5% liked)
Asklemmy
43891 readers
865 users here now
A loosely moderated place to ask open-ended questions
If your post meets the following criteria, it's welcome here!
- Open-ended question
- Not offensive: at this point, we do not have the bandwidth to moderate overtly political discussions. Assume best intent and be excellent to each other.
- Not regarding using or support for Lemmy: context, see the list of support communities and tools for finding communities below
- Not ad nauseam inducing: please make sure it is a question that would be new to most members
- An actual topic of discussion
Looking for support?
Looking for a community?
- Lemmyverse: community search
- sub.rehab: maps old subreddits to fediverse options, marks official as such
- [email protected]: a community for finding communities
~Icon~ ~by~ ~@Double_[email protected]~
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Software Engineering. 16 sigfigs across 64 bits
TIL a 64-bit float is accurate to 16 sigfigs.
Edit: actually, out of curiosity I decided to try and calculate it. I've very possibly done the wrong calculation, but what I did was log~2~(10^x^)=64, which works out to x≈19. Which isn't 16, but is very close, and when you consider the way the float actually works it wouldn't be too surprising that it was lose some information (the sign bit, for example, is immediately completely lost in this context).
A 64 bit IEEE float has 53 significant bits (the “mantissa” or “significand”), and log~10~(2^53^) is 15.9546.
Yeah I wasn't sure if it would be correct to throw out the exponent entirely or if it might end up contributing some amount to the final accuracy of the number. I hadn't spent a lot of time thinking about the problem.
Yeah the exponent just allows you to represent lots of magnitudes, but it wouldn’t contribute to the accuracy because you basically have 1.xyz * 2^exponent^. So the xyz significand is the only part that counts for significant digits. Although I guess in some sense you are partially right, because the exponent exists it is assumed that the first bit is always one, since otherwise you would just adjust the exponent to the first one, so only 52 bits have to be stored.
Isn't it just 15 significant figures then?
I would round up to 16.
Software Engineering too, I just use
std::numbers::pi
. Don't know how many digits it is offhand.I use M_PI and generally don't care unless the device acts funny.