0
What is a Single Precision number in C++?
Is it a number with 8 digits? If so, does the number of digits include the sign and decimal point or without them? Is -12.345678 a single precision number? Like to see some examples of single precision numbers.
2 Respostas
+ 3
Here's a link to a previous discussion:
https://www.sololearn.com/Discuss/660920/?ref=app
+ 2
Single precision numbers (floats) have 7.225 digits of decimal precision; we call it 8 because the 8th digit is partially faithful (enough to include it). I don't think it matters where the decimal point is (or whether it's negative, though selecting a negative number can confuse people slightly).
Here's someone explaining how you get to to 8 (actually just over 7) digits of precision in the first place, to support "is it a number with 8 digits?":
https://stackoverflow.com/questions/30688422/is-the-most-significant-decimal-digits-precision-that-can-be-converted-to-binary
I realize you may not want to look as closely as I did, so that's a partial answer (since I didn't look at additional numbers).
Over the technical line: I made an example of your example; I'm including it here just to be complete. This puts 7.225 decimal precision digits under a microscope and tries to show that the 8th digit is unreliable / sometimes faithful. The 'extremely technical' section goes one step further into how + why.
https://code.sololearn.com/c26j9deIV9DC/?ref=app