Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Printing floating point numbers in binary (johndcook.com)
5 points by ibobev 4 hours ago | hide | past | favorite | 1 comment
 help



In JavaScript, it's

    Math.PI.toString(2)
Who knows how optimized Python or JavaScript's implementations are, but I'd imagine printing the binary representation of floating point numbers is relatively easy to implement manually because you'd just take 1 followed by the bits of the mantissa, then move the decimal point based on the exponent.



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: