Skip to content

v1.2.2

Latest

Choose a tag to compare

@gmpassos gmpassos released this 26 Aug 02:15
71f2f44

Bug-fix release: fixes the two reported issues plus 7 more found while auditing the package.

Reported issues

  • Decimal division by a value lower than 1 (e.g. 5 / 0.5) threw an assert/ArgumentError for an invalid negative precision. (#14)
  • standardDeviation returned NaN for a collection of equal double values. Statistics and StandardDeviationComputerNum now use Welford's online algorithm, which is numerically stable and returns exactly 0.0 for equal elements. It also fixes a loss of precision for collections of large values. (#12)

Other fixes

  • Statistics.operator + merged standardDeviation from the BigInt sums, which are truncated for a non-integer collection, giving a wrong result. It now uses the parallel variance algorithm (Chan et al.).
  • Decimal modulo (operator %, moduloInt, moduloBigInt, moduloDynamicInt) was not Euclidean for a fractional Decimal: -7 % 3 was 2 but -7.5 % 3 was -1.5.
  • DynamicInt.digits counted the - sign for values with 10 or more digits. Since digits sets the precision of the division remainder refinement, (-a) / b and -(a / b) could differ.
  • Statistics.compute, in the BigInt branch:
    • fractional values were truncated. The branch is selected automatically when max > (maxSafeIntSqrt ~/ length), so a plain List<double> of large values was silently corrupted.
    • the overflow check ignored min.abs(), so a collection of large negative values overflowed the int squares sum.
    • sum/squaresSum were clamped to the maximum int when the BigInt value didn't fit.
  • UnitLength: mi to mm/mic/nm used a mile of 1609 m instead of the exact 1609.344 m.
  • 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 follows RFC 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