Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Pretty cool.

Can we use WolframAlpha to show why 0.1 cannot be represented as a floating binary?

And why floating numbers shouldn't be used for currency operations.



Yes.

http://www.wolframalpha.com/input/?i=1%2F10+in+base+2

TL;DR: 1/10 has an infinite repeating binary expansion. (think 1/3 in decimal - 0.3333333) The part that really gets you into trouble is that the repeating pattern is 0011, which means it rounds differently depending on how many digits of precision you give it.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: