-
Notifications
You must be signed in to change notification settings - Fork 1.3k
redo time.monotonic() to avoid double precision #343
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
Conversation
return mp_obj_new_float(common_hal_time_monotonic() / 1000.0); | ||
uint64_t time64 = common_hal_time_monotonic(); | ||
// 4294967296 = 2^32 | ||
return mp_obj_new_float(((uint32_t) (time64 >> 32) * 4294967296.0f + (uint32_t) (time64 & 0xffffffff)) / 1000.0f); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does precision change with this? Would we get more precision by dividing by 1000.0f earlier?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could distribute the division among the two halves, but the precision is still lost due to single-precision floating point. So I don't believe it will make a difference:
>>> (2.0**22+1)/1000 - (2.0**22+0)/1000
0.0
>>> (2.0**22+2)/1000 - (2.0**22+1)/1000
0.00195313
>>> (2.0**22+3)/1000 - (2.0**22+2)/1000
0.0
>>> (2.0**22+4)/1000 - (2.0**22+3)/1000
0.00195313
>>>
This is awesome! Would you mind waiting to add framebuf until 3.x? It'll
give us some code size flexibility with 3.x.
…On Mon, Oct 16, 2017 at 8:53 PM Dan Halbert ***@***.***> wrote:
Gains back 3044 bytes! Framebuf would now fit, with 56 bytes to spare,
before any -finline-limit trickery.
------------------------------
You can view, comment on, or merge this pull request online at:
#343
Commit Summary
- Set DRVSTR on output pins to strong (more current capability).
- redo time.monotonic() to avoid double precision
File Changes
- *M* atmel-samd/common-hal/digitalio/DigitalInOut.c
<https://github.com/adafruit/circuitpython/pull/343/files#diff-0> (3)
- *M* shared-bindings/time/__init__.c
<https://github.com/adafruit/circuitpython/pull/343/files#diff-1> (4)
Patch Links:
- https://github.com/adafruit/circuitpython/pull/343.patch
- https://github.com/adafruit/circuitpython/pull/343.diff
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#343>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AADNqRdW_Ouc3Q_opHsOtp_zYqkkPSJdks5stCSpgaJpZM4P7i74>
.
|
Deferring is fine with me, to 2.2 or 3.0. Limor would like to change the font in framebuf from 8x8 to 8x5 anyway. |
Gains back 3044 bytes! Framebuf would now fit in non-Express, with 56 bytes to spare, before any
-finline-limit
trickery. Implements #342.