Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Fixed numeric aggregations such as `SUM`, `AVERAGE` and `MAX` reading a cell reached through `INDEX`, `CHOOSE`, `IF`, `IFS`, `SWITCH`, `XLOOKUP` or a named expression as a value: as with a direct reference, its text, booleans and blanks are now ignored. [#1768](https://github.com/handsontable/hyperformula/pull/1768)
- Fixed the `ADDRESS` function adding the sheet separator (`!`) when the `sheetName` argument is an empty argument slot (e.g. `=ADDRESS(2,3,1,FALSE(),)` now returns `R2C3` instead of `!R2C3`), while an explicit `""` still adds it. [#1641](https://github.com/handsontable/hyperformula/issues/1641)
- Fixed `IMSUM`, `IMPRODUCT` and `TEXTJOIN` throwing an uncaught `RangeError` for very large ranges, such as `=IMSUM(A1:D40000)`, which stopped the recalculation; they now return a result or an error value in the cell. [#1901](https://github.com/handsontable/hyperformula/pull/1901)
- Fixed cell values smaller than about `1e-298` being returned as `NaN` instead of the rounded number when the `smartRounding` option is on, which is the default. [#1837](https://github.com/handsontable/hyperformula/pull/1837)

## [3.5.0] - 2026-10-09

Expand Down
7 changes: 7 additions & 0 deletions hyperformula/src/Exporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ export class ExportedNamedExpressionChange {
}
}

/** The largest number of significant digits Number.prototype.toPrecision accepts. */
const MAX_TO_PRECISION_DIGITS = 100

export class Exporter implements ChangeExporter<ExportedChange> {
constructor(
private readonly config: Config,
Expand Down Expand Up @@ -132,6 +135,10 @@ export class Exporter implements ChangeExporter<ExportedChange> {
}
const magnitudeMultiplierExponent = Math.floor(Math.log10(Math.abs(value)))
const placesMultiplier = Math.pow(10, this.config.precisionRounding - magnitudeMultiplierExponent)
if (placesMultiplier === Infinity) {
// For tiny values the multiplier overflows and the formula below would return Infinity / Infinity = NaN.
return Number(value.toPrecision(Math.min(this.config.precisionRounding + 1, MAX_TO_PRECISION_DIGITS)))
}
if (value < 0) {
return -Math.round(-value * placesMultiplier) / placesMultiplier
} else {
Expand Down
Loading