-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
float-int conversion problem #666
Comments
I’m not sure I understand the “strangeness”. floats can only represent about 7 significant digits. https://en.m.wikipedia.org/wiki/Single-precision_floating-point_format |
CircuitPython and MicroPython use a modified single-precision floating point representation. It's a conventional 32-bit IEEE float with the bottom two bits set to zero (parts of encoding pointers, ints, and floats in a single-word format). There are 8 bits of exponent and 22 bits of mantissa. Further explication in #230 (comment). |
I think it strange that the implementation doesn't understand it's own limitations when it comes to printing numbers. I expect it to work like cpython or say so when it can't. At least it's suprising behaviour for someone not steeped in the implementation. And loosing whole number precision is very suprising, for me at least, but then again I have never looked at how float is implemented.
I'm looking at implementing time.localtime() (and time/mktime) which in cpython can take a float. But with these limitations, it doesn't seem possible:
|
Strange things happen above (1 << 22):
More strangeness:
The text was updated successfully, but these errors were encountered: