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

Sure. These decisions are tricky, I had this concern in `realistic` too.

My `Rational` type is the "big rationals" (the finite subset of rational numbers I can represent with your available RAM) and these are certainly able to precisely represent any 32-bit or 64-bit float which isn't NaN or an infinity. However, vice versa is not true of course. 0.1 is a very easy Rational, but of course binary floating point cannot represent this exactly.

In the end I punted, TryInto<Rational> is implemented for f32 and f64 but the opposite is not provided at all.



Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

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

Search: