Repository navigation
redo time.monotonic() to avoid double precision - #343
Merged
Merged
Conversation
tannewt
reviewed
Oct 17, 2017
| 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); |
Member
There was a problem hiding this comment.
How does precision change with this? Would we get more precision by dividing by 1000.0f earlier?
Collaborator
Author
There was a problem hiding this comment.
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
>>>
Member
|
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>
.
|
Collaborator
Author
|
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Gains back 3044 bytes! Framebuf would now fit in non-Express, with 56 bytes to spare, before any
-finline-limittrickery. Implements #342.