Skip to content

Make time.time() return float #6625

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

Closed
wants to merge 3 commits into from

Conversation

tekktrik
Copy link
Member

First real contribution! Still pretty new to C/C++ as opposed to Python, but looking around, I think this is the fix for #3125, by casting it as a float. If I understand correctly, this will default to using float or double depending on the board's implementation.

@tekktrik
Copy link
Member Author

But do let me know if that's not correct, honestly just trying to learn, so the recitation is mostly for me :D

@dhalbert
Copy link
Collaborator

dhalbert commented Jul 20, 2022

The reason not to do this is that single precision floats are only about 5-1/2 digits of accuracy, so we lose resolution if the values are cast to float. Try calling time.time() multiple times from the REPL with this change: I think you will see the value not change very often.

@tekktrik
Copy link
Member Author

You're right, and it's probably better to keep the type consistent between ports. Happy to close since I don't have any obvious solution that. Was fun to try anyway!

@tekktrik tekktrik closed this Jul 21, 2022
@dhalbert
Copy link
Collaborator

No problem, and it's great you are seeing how to make changes like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants