DK96-OS / MathTools

Mathematical Software Components. This library is actively maintained, and aims to stay updated. New feature proposals are welcome, but may not be included.
Apache License 2.0
2 stars 1 forks source link

Array Statistics Operations Integer Overflow #35

Open DK96-OS opened 2 years ago

DK96-OS commented 2 years ago

Array Statistics contains functions that calculate the mean and standard deviation of Number Array types.

The Calculate Mean function of ByteArray uses a sum method with an Int return type, which will overflow with enough elements.

_Originally posted by @DK96-OS in https://github.com/DK96-OS/MathTools/pull/32#discussion_r794927783_

DK96-OS commented 2 years ago

ByteArrayExt provides a sum method that uses a long return type. This method is now implemented by the Array Statistics calculateMean functions, as of #55.

DK96-OS commented 2 years ago

LongArrayExt provides a sum method that uses BigInteger return type. This method is now implemented by Array Statistics calculateMean function.

DK96-OS commented 2 years ago

The Guava library can be used. Methods like checkedAddition are nice, but will they affect performance?