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

Wrong percent value for 53% #12

Open
smatsudajp opened this issue Sep 21, 2018 · 0 comments
Open

Wrong percent value for 53% #12

smatsudajp opened this issue Sep 21, 2018 · 0 comments

Comments

@smatsudajp
Copy link

When max is 100 (default) and progress is 53, drawTextContent() writes "52%" rather than the expected "53%".
int percent = (int) (((float) progress / (float) max) * 100);
Seems like 53.0 / 100.0 results in 0.5299...
The same issue for 59%.
Suggestions:
(1) Check if max is 100, and if so, use progress as percent -- this must be very safe
(2) Add 0.5 before casting to int -- this might not be safe. Which do we want when, for example, progress is 2 and max is 30, 6% or 7%?

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

No branches or pull requests

1 participant