Repository navigation
Bug-fix release: fixes the two reported issues plus 7 more found while auditing the package.
Reported issues
Decimaldivision by a value lower than1(e.g.5 / 0.5) threw anassert/ArgumentErrorfor an invalid negative precision. (#14)standardDeviationreturnedNaNfor a collection of equaldoublevalues.StatisticsandStandardDeviationComputerNumnow use Welford's online algorithm, which is numerically stable and returns exactly0.0for equal elements. It also fixes a loss of precision for collections of large values. (#12)
Other fixes
Statistics.operator +mergedstandardDeviationfrom theBigIntsums, which are truncated for a non-integer collection, giving a wrong result. It now uses the parallel variance algorithm (Chan et al.).Decimalmodulo (operator %,moduloInt,moduloBigInt,moduloDynamicInt) was not Euclidean for a fractionalDecimal:-7 % 3was2but-7.5 % 3was-1.5.DynamicInt.digitscounted the-sign for values with 10 or more digits. Sincedigitssets the precision of the division remainder refinement,(-a) / band-(a / b)could differ.Statistics.compute, in theBigIntbranch:- fractional values were truncated. The branch is selected automatically when
max > (maxSafeIntSqrt ~/ length), so a plainList<double>of large values was silently corrupted. - the overflow check ignored
min.abs(), so a collection of large negative values overflowed theintsquares sum. sum/squaresSumwere clamped to the maximumintwhen theBigIntvalue didn't fit.
- fractional values were truncated. The branch is selected automatically when
UnitLength:mitomm/mic/nmused a mile of1609m instead of the exact1609.344m.- CSV (
normalizeCSVValue,generateCSV): a"inside a value was not escaped as"", and column names containing the separator were not quoted — both corrupt the document. Now followsRFC 4180.
Tests
Added regression tests for every fix above, including cross-checks of the whole UnitLength conversion table, Decimal modulo/division matrices against num, and a CSV round trip through an RFC 4180 parser.
Full Changelog: v1.2.1...v1.2.2