Closed amaembo closed 1 year ago
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.
* 0x1.0p64
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:
As
* 0x1.0p64
is basically an exponent change, we don't have any machine precision problems here.