+ 1

Floating point representation

https://code.sololearn.com/c2B6a34Mnox0/?ref=app Please tell me the reason for why there is 1 in the last bit ~ swim ~ 👑 Prometheus 🇸🇬

16th May 2020, 8:07 AM
Shubham kumar
Shubham kumar - avatar
1 Resposta
+ 6
It's because of how they're stored in binary. The relevant repeating binary approximation stored leads to this. For example, 1/10 is represented by: 0.0001100110011001100110011001100110011001100110011... Terminate this at any value, and you get an imprecise value when converted back to decimal.
16th May 2020, 8:14 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar