Skip to content
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

examples: Improve: Round battery level to display friendly format #3100

Merged
merged 2 commits into from
Nov 25, 2024

Conversation

danoh
Copy link
Contributor

@danoh danoh commented Nov 24, 2024

Current code, after fix from #1887, generates sometimes weird results. For example, for battery level 0.99 is the result 90.10000000000001, due to float conversions.

I propose a fix that rounds the result to one decimal place, which should be fine for battery levels expressed in percentages. Rounding to whole numbers might even work well in this case.

@zuckschwerdt
Copy link
Collaborator

I think users won't expect any more precision than a whole number, i.e. round(0).

@danoh
Copy link
Contributor Author

danoh commented Nov 25, 2024

agreed and changed the pull request

@zuckschwerdt zuckschwerdt merged commit cd9c40c into merbanan:master Nov 25, 2024
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