Skip to content

Fix incorrect rounding of Module effect percentages. #99

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

Merged
merged 1 commit into from
Nov 3, 2024

Conversation

Olipro
Copy link
Collaborator

@Olipro Olipro commented Nov 3, 2024

Due to the JSON having 32-bit IEEE-754 float values, numbers such as 0.04 are encoded as 0.0399999... which subsequently requires adjusting to the nearest decimal.

Previously, we were multiplying up by 100, but in the case of the above number, this results in obtaining 3.99999 and then truncating it to 3.

Now, we multiply by 1000 and use the Math.Round feature to round up and eliminate any decimals, followed by restoring it to a double precision representation.

fixes #95

Due to the JSON having 32-bit IEEE-754 float values, numbers such as
0.04 are encoded as 0.0399999... which subsequently requires adjusting
to the nearest decimal.

Previously, we were multiplying up by 100, but in the case of the above
number, this results in obtaining 3.99999 and then truncating it to 3.

Now, we multiply by 1000 and use the Math.Round feature to round up and
eliminate any decimals, followed by restoring it to a double precision
representation.

fixes DanielKote#95
@DanielKote
Copy link
Owner

Sounds good. Thanks.

@DanielKote DanielKote merged commit f16ef8a into DanielKote:Main Nov 3, 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.

Productivity bonuses cannot be set
2 participants