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

IntCollector.averaging/LongCollector.averaging could be optimized #268

Closed
amaembo opened this issue Sep 2, 2023 · 0 comments
Closed

IntCollector.averaging/LongCollector.averaging could be optimized #268

amaembo opened this issue Sep 2, 2023 · 0 comments
Milestone

Comments

@amaembo
Copy link
Owner

amaembo commented Sep 2, 2023

Currently, the final result could be computed using BigDecimal, which is slow and requires allocations. It looks like, we can do this in a simpler way using plain math:

OptionalDouble.of(((double) (hi + (lo < 0 ? 1 : 0)) / cnt) * 0x1.0p64 + ((double) lo) / cnt)

As * 0x1.0p64 is basically an exponent change, we don't have any machine precision problems here.

@amaembo amaembo added this to the 0.8.2 milestone Sep 2, 2023
@amaembo amaembo closed this as completed Sep 2, 2023
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