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

I'm not sure, but generally speaking converting doubles to strings will fail to round trip at least the NaNs

If round tripping is important, my recommendation would be to output something that directly corresponds to the binary representation of the float. For example, printf %a



See this article for an in-depth look at implementing these conversions: https://research.swtch.com/ftoa




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

Search: