Repository navigation
fix: an empty string is no longer coerced to 0 in numeric contexts (HF-361) - #1768
Conversation
`ArithmeticHelper#coerceNonDateScalarToMaybeNumber` special-cased an
empty string ('') to coerce to 0, the same as a truly blank cell
(EmptyValue). This is a different case from EmptyValue -- a cell or
literal holding '' is text, not blank -- and it made HyperFormula
diverge from Excel in two ways:
- Arithmetic on '' returned 0 instead of #VALUE! (e.g. `=""+0`).
- COUNT("") returned 1 instead of 0, since the literal argument was
coerced to 0 (an ExtendedNumber) before COUNT's own
isExtendedNumber predicate ever saw it.
Root cause:
- Interpreter.ts `plusOp`/`minusOp`/etc. call
`ArithmeticHelper#coerceScalarToNumberOrError`, which returned 0
for '' before this fix.
- NumericAggregationPlugin#reduce (used by COUNT, SUM, AVERAGE,
PRODUCT, MIN, MAX) calls the same coercion for a literal/expression
argument (as opposed to a direct cell reference, which uses the
aggregation's own predicate without numeric coercion) -- so
COUNT("") went through the same 0-producing bug before
isExtendedNumber(0) counted it.
This removes the `arg === ''` special case, letting '' fall through
to the normal string-to-number parsing (which correctly fails for
non-numeric text), matching how HyperFormula already treats any
other non-numeric string literal (e.g. `SUM("abc")` already returned
#VALUE!; `SUM("")` was the sole inconsistent exception).
Not affected (verified with tests): blank cells (EmptyValue) still
coerce to 0 in arithmetic and are still governed separately by
`evaluateNullToZero`; a '' criterion in COUNTIF/SUMIF-style functions
still matches only genuinely blank cells (Criterion.ts resolves that
case before any numeric coercion runs).
This is a breaking change.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
hyperformula-docs | f494586 | Commit Preview URL Branch Preview URL |
Nov 19 2026, 04:07 PM |
The fix itself was already in place; this adds what a breaking change owes
the reader, and moves the tests where this repo keeps them.
- Changelog: moved the entry from Fixed to Changed and rewrote it in the
"A **breaking change**:" form the other 4.0 entries use, with a migration
guide link and the PR number instead of an internal task id.
- Migration guide: new docs/guide/migration-from-3.x-to-4.0.md (plus its
sidebar entry) with a section on empty-string coercion. Every before/after
value in it is measured, not assumed -- two rounds of probes across the
unpatched and patched engine, plus the assertions the private suite already
pinned. That caught two wrong claims: DATE("","","") returned #NUM! and not
a computed date, and ACOT("") returned 1.5707963267949 -- a plausible number
from an argument that was never numeric, which is the most useful example
this change has.
- Removed test/hf-361-empty-string-coercion.spec.ts. DEV_DOCS.md:129 is
explicit that interpreter specs do not live in the public repo, because a
copy here runs twice and leaves develop red if only one of the paired PRs
lands. Those tests move to the paired hyperformula-tests branch of the same
name.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Performance comparison of head (f494586) vs base (9ea6b41) |
…n guide
Two independent reviews converged on the same defect: both documents implied
that a cell holding an empty string breaks any numeric formula. It does not.
Measured on both engines: SUM, AVERAGE, MIN, MAX and COUNT over a reference
or a range are byte-identical before and after -- they have always ignored
text found there, matching Excel -- because the aggregation path filters
strings out before this coercion is reached. Only arithmetic, number-typed
arguments, and an empty string written directly into an aggregation change.
A reader with =SUM(A1:A100) would have been told to expect a break that
cannot happen, in a document whose whole job is to predict breaks.
Also corrected or added, all measured rather than read off a test:
- =ACOT("") returned 1.5707963268, not 1.5707963267949. I had taken the
digits from the private suite's toBeCloseTo(..., 10) assertion, which
passes for both. Default config rounds to 10 significant digits.
- =DATE(A1, 2, 3) over a text empty string silently returned 35 -- a date in
1900 -- which is the same "answered instead of failing" class as ACOT and a
better example, because it is the reference form users actually write.
- Added the contexts the table omitted while claiming to be exhaustive:
=""%, =SUM(1, ""), =ABS, =INT, =SUMSQ, =MEDIAN, =STDEV.
- Added the nested-expression class (=SUM(IF(TRUE,"",1)), =SUM(LEFT("abc",0))),
where 3.x was wrong and 4.0 matches Excel, and the one class that moves away
from Excel (an argument Excel evaluates as an array of only text), with the
pre-existing non-array-aware IF that actually causes it.
- Fixed the code blocks against DOCS_CONTENT_GUIDE: the mandated
{ sheet, row, col } key order, a snippet that actually runs as written
(verified), and an untagged fence for the before/after pair that is not
JavaScript. Pointed N() and IFERROR at their real category anchors.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit c99427b. Configure here.
Tobiadefami
left a comment
There was a problem hiding this comment.
Could we preserve reference handling through parentheses? With B1 containing ="", =SUM((B1)) returns 0 in Excel Online and on base, but #VALUE! on this head.
A possible fix is to recursively look through parentheses when checking for CELL_REFERENCE in NumericAggregationPlugin.reduce(). I tested this temporarily: it fixes the regression while preserving rejection of literal empty strings. All 195 tests across 16 checked suites passed.
…eric aggregations Reported in review on this PR: with B1 holding ="", SUM(B1) correctly returns 0 (aggregation over a reference ignores non-numeric text, unchanged by this PR), but SUM((B1)) returned #VALUE!. Root cause: NumericAggregationPlugin#reduce decides how to treat an argument by checking arg.type against CELL_REFERENCE (and separately against CELL_RANGE/COLUMN_RANGE/ROW_RANGE) to tell "this is a reference, ignore its non-numeric text" apart from "this is a literal/computed value, coerce it to a number." A parenthesized argument reaches the reducer as a PARENTHESIS node wrapping the real expression, so neither check matched and (B1) fell through to the same coercion "" now correctly fails for as a literal. reduce() is the single shared implementation behind SUM, SUMSQ, COUNT, COUNTA, AVERAGE, AVERAGEA, MIN, MAX, MINA, MAXA, PRODUCT, VAR.S/P, VARA/VARPA and STDEV.S/P/A/PA (via doAverage/doCount/reduceAggregate(A)/doMax/doMin/ doSum/doProduct), so this was not SUM-specific: every one of those reproduced the same #VALUE! regression through a single extra pair of parentheses. Fix: unwrap PARENTHESIS nodes before either arg.type check, the same idiom already used in FunctionPlugin#runFunctionWithReferenceArgument and InformationPlugin. PARENTHESIS is a pure passthrough in Interpreter#evaluateAst, so this only changes which branch classifies the argument, not what evaluateAst(arg, state) itself returns. Verified against Excel Online via MS Graph: a parenthesized reference or range behaves identically to the bare one in every case tested (single and double parentheses, SUM/COUNT/AVERAGE/MIN/MAX/PRODUCT/SUMSQ/STDEV, a range containing an embedded empty string). Ranges wrapped in parentheses already worked before this fix -- they take a different path in reduce() that checks the evaluated value's runtime type (SimpleRangeValue) rather than the AST node type -- so this fix does not change range handling, only single-cell (and column/row) references. Paired failing-then-passing tests: handsontable/hyperformula-tests, same branch, "parentheses around a reference do not change numeric-aggregation behavior" in empty-string-coercion.spec.ts. Negative control: reverting this commit's source change while keeping those tests fails 5 of the 8 new specs (the 3 that also pass without the fix are pins on already-correct behavior: COUNT((A1)) and the two parenthesized-range cases). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
@Tobiadefami reproduced and fixed — thanks for catching it, and sorry it sat this long.
That choke point ( Verified against Excel Online (MS Graph, live session): parentheses are fully transparent to reference handling in every case I measured — single and double parens, the whole aggregation family, and a parenthesized range containing an embedded Added 8 specs to the paired repo ( One caveat I want to be explicit about: I could not run the Karma/Jasmine browser leg locally — no headless browser in my environment — so I pushed rather than claim it green. CI is running it now on
|
|
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # CHANGELOG.md
|
Fixed in a24a523, along the lines you suggested: The branch is now up to date with |
…and the migration guide Drop two search tags that repeat the page's own heading, and shorten the comment on the parenthesis unwrap to the behaviour it implements. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rFormula needs `=SUM(IF(TRUE,"",1))` returns #NAME? in HyperFormula, because TRUE is a function there, not a literal; the table's values hold for `TRUE()`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the array arithmetic mode disabled, IF returns a single value, so
=SUM(IF(A1:A3>0,"",A1:A3)) is #VALUE! and =COUNT(IF({1,0},"",5)) is 0, where
Excel gives 0 and 1. With the mode enabled the results match. The migration
guide now says the case depends on the mode and which cell the example sits in.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d and drop the migration guide Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, not an empty cell Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md # docs/guide/list-of-differences.md
…ifferences from Excel Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The |
…gations The numeric aggregations ignored non-numeric values only in an argument written as a reference or a range. A value that INDEX, CHOOSE or IF returned from a cell, or that a named expression defined as a reference read, was coerced like a literal, so text made SUM, AVERAGE, MIN and MAX return #VALUE!, and an empty string started to do the same once it was no longer read as 0. An argument is now read as a reference when its formula can only evaluate to the content of a referenced cell: INDEX over a reference, a named expression defined as a reference, or IF and CHOOSE whose result arguments are all references or number literals. The decision looks at the formula only, so no argument is evaluated twice. A literal such as IF(TRUE(),"",1) is still read as a value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Added comes before Changed in the Unreleased section, as on develop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ents The registry lookup now runs only for these three function calls. The changelog entry states the rule: a cell reached through INDEX, CHOOSE, IF or a named expression is read like a direct reference, so its text, booleans and blanks are ignored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The built-in IF and CHOOSE record which argument they returned, and the numeric aggregations read that record after evaluating the argument. An empty string or other text reached through the selected reference is then ignored even when another result argument is a text literal, as in =SUM(IF(TRUE(),A2,"")), =SUM(IF(TRUE(),A2)) and =SUM(CHOOSE(1,A2,"")). No argument is evaluated a second time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ions Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Warning
High risk: Changes core numeric coercion semantics in ArithmeticHelper used by every arithmetic operation, and rewrites the argument-handling loop of all numeric aggregations (SUM/COUNT/MIN/…) including a new cross-plugin AST-tracking mechanism, so miscalculation or crashes could affect a wide range of formulas.
Full review: no issues found.
Want a deeper review? Comment /review improve on its own line: a full review of the latest commit with an extra fix-oriented pass (about 2x the cost).
Tobiadefami
left a comment
There was a problem hiding this comment.
The fixes from the last round check out: INDEX, IF, IFS, SWITCH, CHOOSE, parentheses and names now keep reference semantics. Two routes still turn a 0 from develop into #VALUE!: XLOOKUP, and INDEX over IF or CHOOSE with array arithmetic on. Details below.
… aggregations (HF-361) XLOOKUP records whether it returned from return_array or from if_not_found, in the same record that IF, IFS, SWITCH and CHOOSE use, so SUM, AVERAGE and the other numeric aggregations ignore text it returns from a reference, as in Excel. In array arithmetic mode, IF, IFS, SWITCH and CHOOSE keep the record when they return a range from a single argument, so INDEX over them reads a reference; an array built cell by cell from an array condition, selector or case value still has no record. No argument is evaluated twice. Empty text used as a number now returns #VALUE!, so the list of differences no longer lists it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Warning
High risk: The change alters core evaluation paths for SUM/COUNT-class aggregations and adds cross-plugin global state (WeakMap + per-plugin-instance argument cache) keyed to IF/IFS/SWITCH/CHOOSE/XLOOKUP, so a mistake silently changes results of very common formulas.
Incremental review: 1 potential issue(s).
docs/guide/list-of-differences.md:120
SEQUENCE(0) documented as #CALC!, an error HyperFormula cannot return
Low severity
The row for =SEQUENCE(0) now lists HyperFormula's result as CALC, changed from VALUE, although no change in this PR touches SEQUENCE and HyperFormula's ErrorType enum has no #CALC! member, so the engine cannot produce it. The same diff deletes the CONCAT row that explicitly said '#CALC!, which HyperFormula does not have', removing the statement that contradicts the new claim. The table is now internally inconsistent (the TAKE rows still show HyperFormula returning N/A where Excel returns CALC) and documents behaviour the engine does not exhibit.
Suggestion: Revert the SEQUENCE row to VALUE (or whatever the engine actually returns) and restore the CONCAT 32767-character row, unless a separate engine change that this PR does not contain justifies them.
Want a deeper review? Comment /review improve on its own line: a full review of the latest commit with an extra fix-oriented pass (about 2x the cost).
Tobiadefami
left a comment
There was a problem hiding this comment.
Both blocking points are fixed at 0dcb986. On this head, =SUM(XLOOKUP(2,D1:D3,A1:A3)) is 0 and =AVERAGE(XLOOKUP(2,D1:D3,A1:A3),2) is 2, with array arithmetic off and on, and =SUM(INDEX(CHOOSE(1,A1:A3),2)) and =SUM(INDEX(IF(TRUE(),A1:A3),2)) are 0 with array arithmetic on, as Microsoft Excel Online returns. The specs in hyperformula-tests cff2073e0 cover them.
An empty string given as RANK.EQ's number or order now returns #VALUE!, as in Excel. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1768 +/- ##
===========================================
+ Coverage 97.49% 97.61% +0.11%
===========================================
Files 210 212 +2
Lines 17036 17923 +887
Branches 3841 4157 +316
===========================================
+ Hits 16610 17496 +886
- Misses 418 427 +9
+ Partials 8 0 -8
🚀 New features to boost your workflow:
|
…eys (HF-361) (#1907) ### Context Follow-up to #1768 (HF-361). With array arithmetic on, `XLOOKUP` over an array of keys dropped its `if_not_found` argument as the returned argument, so `INDEX` of its result was read as a value. With `A2` holding `=""`, `=SUM(INDEX(XLOOKUP({5,6},D1:D3,A1:A3,A2),1,1))` returned `#VALUE!`; Excel returns 0, because every key is missing and each element comes from the `if_not_found` reference. This PR keeps `if_not_found` as the returned argument when every lookup of an array of keys returned it. If at least one key is found, this PR records no returned argument, as before. That path cannot be observed yet, because such a call throws with array arithmetic on (see Out of scope). Excel decides per element: an element taken from `if_not_found` stays a reference (`{2,5}`, column 2: 0) and an element found in `return_array` is a value (`{1,2}`, column 2: `#VALUE!`). A literal `""` as `if_not_found` still gives `#VALUE!`. The change is in `LookupPlugin.xlookup` and the `SelectedArgument` doc comment. ### How did you test your changes? Paired branch `fix/hf-361-xlookup-array` in `hyperformula-tests`: three cases in `function-sum.spec.ts`: the all-missing keys, the literal `""` control, and `#N/A` without `if_not_found`. - `function-sum.spec.ts` with this branch and the paired branch: 62 passed, 62 total. - Full Jest at this commit with the paired branch, after merging develop: 569 suites passed, 14885 tests passed, 3 skipped. `tsc` and `eslint`: exit 0. - Mutation: with develop's `LookupPlugin.ts`, the new test fails (1 failed, 61 passed, 62 total in the SUM spec). - Not covered by a failing test: a mutant that never forgets the selected argument survives, because every array of keys with a found key throws, on develop and on this branch (see below). ### AI assistance Claude Code wrote the change and the paired tests and ran the mutation and the Jest runs. The Excel values come from a measured run, not from the model. ### Compatibility with Excel and Google Sheets Excel Online, 20 Nov 2026, all controls passed. `A1:A3` = 1, `=""`, 3; `D1:D3` = 1, 2, 3. HyperFormula with `useArrayArithmetic: true`. | Formula | Excel | Google Sheets | HyperFormula (develop) | HyperFormula (this PR) | |---|---|---|---|---| | `=SUM(INDEX(XLOOKUP({5,6},D1:D3,A1:A3,A2),1,1))` | 0 | Not checked | `#VALUE!` | 0 | | `=SUM(INDEX(XLOOKUP({5,6},D1:D3,A1:A3,A2),1,2))` | 0 | Not checked | `#VALUE!` | 0 | | `=SUM(INDEX(XLOOKUP({5;6},D1:D3,A1:A3,A2),2,1))` | 0 | Not checked | `#VALUE!` | 0 | | `=SUM(INDEX(XLOOKUP({5,6},D1:D3,A1:A3,A2),1,1),5)` | 5 | Not checked | `#VALUE!` | 5 | | `=SUM(INDEX(XLOOKUP({5,6},D1:D3,A1:A3,""),1,1))` | `#VALUE!` | Not checked | `#VALUE!` | `#VALUE!` | `ISREF` on the same `INDEX` result is TRUE in Excel and FALSE in HyperFormula before and after this PR; `ISREF` is not changed here. ### Public API changes None. ### Out of scope and follow-ups - On develop, with `useArrayArithmetic: true`, `XLOOKUP` over an array of keys throws `Function returning array cannot be vectorized.` as soon as one key is found, for example `=XLOOKUP({1,2},D1:D3,A1:A3)`. This PR does not touch it, so the mixed-key cases (`{2,5}`, `{1,2}`) have no HyperFormula test yet. It needs its own task. - Once the throw is fixed, the all-or-nothing rule here would give `#VALUE!` for `{2,5}`, column 2, where Excel gives 0, so per-element tracking is a follow-up (an inference from the diff, not measured). - `ISREF` of an `INDEX` result (see above). ### Types of changes - [x] Bug fix (a non-breaking change that fixes an issue) ### Related issues 1. HF-361, follows #1768. ### Checklist - [ ] My pull request meets the [Definition of Done](https://github.com/handsontable/hyperformula/blob/develop/dev-docs/DEFINITION-OF-DONE.md). External contributors: see also [Contributing to HyperFormula](https://handsontable.com/docs/hyperformula/guide/contributing.html). - [ ] I have signed the [Contributor License Agreement](https://goo.gl/forms/yuutGuN0RjsikVpM2). - [ ] I read my own diff end to end before requesting a review. - [x] No CHANGELOG entry: the unreleased `Fixed` entry of #1768 already covers `XLOOKUP` returning a reference to numeric aggregations, and this PR corrects the same unreleased behaviour. - [x] No documentation change: no public behaviour outside #1768's unreleased entry. - [x] Not a breaking change. - [x] No `dev-docs/` page is affected. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: marcin-kordas-hoc <marcin-kordas-hoc@users.noreply.github.com>
### Context The PR adds the `ERF.PRECISE` function. - **Why:** it is a standard Excel function that HyperFormula did not have, so formulas using it returned `#NAME?`. - **What changed:** - `StatisticalPlugin.ts`: `ERF.PRECISE(x)`, computed by the same `erf` as the one-argument `ERF`. - `ERF.PRECISE` reads its argument through `ArithmeticHelper.coerceScalarToNumberRejectingBooleans`, which `GESTEP` (#1788) added on `develop`: it returns `#VALUE!` for a boolean or the empty text. `ArithmeticHelper.ts` is not changed. - `engineering.ts`: catalogue entry. `functionCapabilities.ts`: `ERF.PRECISE` in the license capability table. - 17 language packs: names from the Excel 2013 translation table (dolf.trieschnigg.nl), a source listed in `hyperformula/dev-docs/I18N.md`, except `ptPT`. That pack uses the Brazilian Portuguese names (`ERF` is `FUNERRO`), so `ERF.PRECISE` is `FUNERRO.PRECISO`, as on Microsoft's pt-BR function page; the table gives the European `FUNCERRO.PRECISO`. - `docs/guide/list-of-differences.md`: a paragraph on accuracy near zero (see Out of scope), a row for `=ERF.PRECISE(A1:B1)` in A5, which returns a number here and `#VALUE!` in Excel, and a row for `=ERF.PRECISE(A1:A3)` with `useArrayArithmetic: true`, which spills one value per cell here. - `CHANGELOG.md`: one entry. - **Result:** `ERF.PRECISE(x)` returns the error function integrated from 0 to `x`. - Numbers, dates, numeric text and empty cells are accepted. - A boolean and the empty text `""` are `#VALUE!`, as in Excel. An error argument is returned. `ERF` and `ERFC` keep their current handling of booleans here; that change is in #1836, which can use the same `coerceScalarToNumberRejectingBooleans`. ### How did you test your changes? - Paired tests branch: `feat/hf-482-erf-precise` in `hyperformula-tests`, spec `unit/interpreter/function-erf.precise.spec.ts`: 72 tests with one assertion each, all passing. Two of them use the Polish name `FUNKCJA.BŁ.DOKŁ`: parsed in a `plPL` engine, and shown in `plPL` for a formula entered in English; both fail when the `plPL` entry is misspelled. Excel Online shows the same Polish name. A third calls `FUNERRO.PRECISO` in a `ptPT` engine and fails with `FUNCERRO.PRECISO`. - With the boolean and empty-text check removed from `coerceScalarToNumberRejectingBooleans`, the 5 boolean cases fail. `""` still gives `#VALUE!`, because `coerceScalarToNumberOrError` has rejected it since #1768. - Full Jest run at this head with the paired tests attached (CI): 16479 passed, 3 skipped, 0 failed, in 582 suites. `tsc --noEmit`: 0 errors. ESLint on the changed `.ts` files (engine and tests): 0 errors; the full lint runs in CI. - 54 `ERF.PRECISE`, `ERF` and `ERFC` formulas were measured earlier in Excel Online (Microsoft Graph). Replayed in HyperFormula at this head, relative tolerance 1e-12: 41 identical, 11 different, 2 not evaluable in Excel (zero and two arguments). - 2: `ERF(TRUE())` and `ERFC(TRUE())` are `#VALUE!` in Excel and numbers in HyperFormula (#1836). - 2: `ERF.PRECISE(1e-10)` and `ERF.PRECISE(1e-300)` lose relative accuracy in the shared `erf` (fixed in #1795). - 6: decimal-separator cases. The Excel account used Polish settings, where `"0,5"` is a number and `"0.5"` is not. - 1: a two-cell range in a one-value argument, recorded in the list of differences. - Edge inputs from the edge matrix (48 cases: empty cell, text, booleans, errors, magnitudes, ranges, array literals, names) measured in Excel Online on 2026-11-05: 14 differ. 10 are ranges of more than one cell, `#VALUE!` in Excel, where HyperFormula takes one cell or spills (the list-of-differences row); 2 are `1e-7` and `1e-300` (accuracy, fixed in #1795); 2 are inputs Excel does not accept (no argument, `1e308`). - The accuracy paragraph was checked against the Maclaurin series of `erf` (60-digit decimal arithmetic) for 120 arguments from `1e-10` to `0.9`: at the 11 significant digits returned by default, every argument from `1e-6` down differs from the exact value, and the largest argument with a different last digit is `1.5e-4`. - Away from zero the results agree with Excel to the 11 significant digits HyperFormula returns by default. ### AI assistance Claude Code (Claude Opus and Claude Sonnet) wrote the code, the tests and the documentation changes in this pull request and in hyperformula-tests#82. Every commit on both branches, other than merges, carries its co-author line. ### Compatibility with Excel and Google Sheets Excel values are the saved Excel Online results. Google Sheets was not measured. | Formula | Data | Excel | Google Sheets | HyperFormula | |---|---|---|---|---| | `=ERF.PRECISE(0.5)` | | 0.520499877813047 | not measured | 0.52049987781 | | `=ERF.PRECISE(-1)` | | -0.842700792949715 | not measured | -0.84270079295 | | `=ERF.PRECISE(E1)` | E1 empty | 0 | not measured | 0 | | `=ERF.PRECISE("1")` | | 0.842700792949715 | not measured | 0.84270079295 | | `=ERF.PRECISE(TRUE())` | | `#VALUE!` | not measured | `#VALUE!` | | `=ERF.PRECISE("")` | | `#VALUE!` | not measured | `#VALUE!` | | `=ERF.PRECISE(F1)` | F1 `=1/0` | `#DIV/0!` | not measured | `#DIV/0!` | | `=ERF.PRECISE(1e-10)` | | 1.12837916709551E-10 | not measured | 1.128379612E-10 | | `=ERF.PRECISE(A1:B1)` in A5 | 0.5, 1 | `#VALUE!` | not measured | 0.52049987781 | ### Public API changes None. The function is listed by `getAvailableFunctions()` like any other built-in function. ### Out of scope and follow-ups - Accuracy near zero: the list-of-differences paragraph added here describes the current `erf`. #1795 fixes it, so whichever of the two merges second drops that paragraph. - English names are kept where the translation table has none: `csCZ`, `daDK`, `enGB` and `idID`. The individual Microsoft pages were checked only for `ptPT`. ### Types of changes - [ ] Breaking change (existing functionality no longer works as before) – agreed with the maintainers - [x] New feature or improvement (a non-breaking change that adds functionality) - [ ] Bug fix (a non-breaking change that fixes an issue) - [x] Additional language file, or a change to an existing language file (translations) - [x] Change to the documentation ### Related issues 1. HF-482 ### Checklist - [x] My pull request meets the [Definition of Done](https://github.com/handsontable/hyperformula/blob/develop/dev-docs/DEFINITION-OF-DONE.md). External contributors: see also [Contributing to HyperFormula](https://handsontable.com/docs/hyperformula/guide/contributing.html). - [ ] I have signed the [Contributor License Agreement](https://goo.gl/forms/yuutGuN0RjsikVpM2). - [x] I read my own diff end to end before requesting a review. - [x] I added a [CHANGELOG.md](https://github.com/handsontable/hyperformula/blob/develop/CHANGELOG.md) entry, written by [the changelog rules](https://github.com/handsontable/hyperformula/blob/develop/dev-docs/DOC-STANDARDS.md#the-changelog) – or none is needed (docs, tests or tooling only). - [x] I updated the documentation and JSDoc to match the change. - [ ] Breaking change only: I added a section to the migration guide. - [x] I updated the `dev-docs/` pages this change affects – or none needed it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Non-breaking additive function with localized names and documentation; numerical behavior reuses existing erf and only adds targeted coercion. > > **Overview** > Adds **`ERF.PRECISE`**, the Excel one-argument Gaussian error integral from 0 to *x*, wired through **`StatisticalPlugin`** using the same **`erf`** implementation as single-argument **`ERF`**. > > Argument handling is stricter for Excel parity: a new **`ArithmeticHelper.coerceScalarToNumberRejectingBooleanOrError`** returns **`#VALUE!`** for booleans and **`""`** (while other coercions still apply). The function is registered in engineering metadata, the license capability list, **17** locale dictionaries, **CHANGELOG**, and **list-of-differences** (multi-cell range vs Excel **`#VALUE!`**, shared near-zero accuracy limits with **`ERF`**/**`ERFC`**). > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit e424abc. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>

Context
The PR stops HyperFormula from reading an empty string (
"") as0in numeric contexts. The numeric aggregations now read a cell reached throughINDEX,CHOOSE,IF,IFS,SWITCHor a named expression like a direct reference to it.""is text, so=""+0returns#VALUE!and=COUNT("")returns0.developreturns0and1.ArithmeticHelper.ts:""has no special case, so the text-to-number parsing finds no number in it.NumericAggregationPlugin.ts: an argument counts as a reference when it is a reference or a range, also in parentheses. So does anINDEXover one, a named expression defined as one, and anIF,IFS,SWITCHorCHOOSEthat returned one.BooleanPlugin.ts: the built-inIF,IFS,SWITCHandCHOOSErecord which argument they returned, and clear that record before each evaluation. The aggregation reads the record, so no argument is evaluated twice.IFERRORandIFNArecord nothing, because in Excel they return the value of the cell:=SUM(IFERROR(A2,0))stays#VALUE!.docs/guide/list-of-differences.md: one row, for a text-onlyIFarray in an aggregation.docs/guide/types-of-values.md: empty a cell withnull, because''is stored as text.CHANGELOG.md: two entries under Fixed.developdiffers on 70.NumericAggregationPluginnow depends on the built-inBooleanPluginandInformationPlugin. A custom plugin registered overINDEX,IF,IFS,SWITCHorCHOOSEis read as a value.How did you test your changes?
fix/hf-361-empty-string-coercioninhyperformula-tests(hyperformula-tests#53). Against itsdevelopit changes 15 spec files. They are the newempty-string-coercionspec, theSUM,AVERAGE,COUNT,MAXandMINspecs, and the specs whose expected results changed.CHOOSEROWStests fromdevelopused""as the row index and expected the index-bounds message. The index is now text, so they expect the number-coercion message, as the"abc"test does; the value stays#VALUE!.SUM,AVERAGE,MAX,MIN,COUNT, empty-string, coercion andCONCATspecs: 245 tests passed.tsc --noEmitandeslint --quiet src: 0 errors.RAND()in selectors, this head gives the same 220 results.RAND()runs at most once per formula.RAND()cases.npm run test:performance: every scenario stays within its own spread, with median changes from -5.7% to +0.9%.IF,CHOOSEandSUM(IF(...))formulas is 5.0% slower (median). Per pair: +0.2%, +11.1%, +4.9%, +13.7%, +5.0%, against a 4% spread of the previous head.IFSandSWITCHis 5.5% slower (median), inside its 10% spread.AI assistance
Claude Code wrote the changes in
ArithmeticHelper,NumericAggregationPluginandBooleanPlugin, the paired tests, the CHANGELOG entries, the guide changes and this description. All 18 non-merge commits on this branch and all 14 on the paired branch carry its co-author line.Compatibility with Excel and Google Sheets
Excel values come from seven runs in Excel Online, replayed here on each head; Google Sheets was not checked. Inputs:
A1:A3holds1,="",3;B1:B3holds1,abc,3;D1holdsabc;G1:G3holds1,2,3.myNameis=Sheet1!$A$2andtxtNameis=Sheet1!$B$2. ThePRODUCTandMEDIANrows useP1empty,P2holding="",P3holdingabcandP4holding5.The 17 differences from Excel are known gaps.
PRODUCTwith no number (7 rows),MEDIANwith text (4 rows),TEXTover text (3 rows) andCOUNTIFwith""(1 row) are follow-ups. The text-onlyIFarray (2 rows) is in the list of differences.Two of these rows moved away from Excel in this PR:
=PRODUCT((P1))and=PRODUCT((P2))returned0ondevelop, as in Excel, and now return1, like=PRODUCT(P1). A parenthesized reference is now read like the bare reference.All 107 formulas measured in Excel and replayed on each head
develop=SUM(IF(TRUE(),A2,""))00#VALUE!0=SUM(IF(TRUE(),A2))00#VALUE!0=SUM(CHOOSE(1,A2,""))00#VALUE!0=SUM(INDEX(A1:A3,2))00#VALUE!0=AVERAGE(INDEX(A1:A3,2),2)21#VALUE!2=SUM(IF(TRUE(),A2,0))00#VALUE!0=SUM(A1:A3)4444=SUM(myName,5)55#VALUE!5=SUM(IFERROR(A2,0))#VALUE!0#VALUE!#VALUE!=SUM(IFNA(A2,0))#VALUE!0#VALUE!#VALUE!=SUM(IFS(TRUE(),A2))00#VALUE!0=SUM(SWITCH(1,1,A2))00#VALUE!0=SUM(IFERROR(1/0,A2))#VALUE!0#VALUE!#VALUE!=SUM(IFERROR("",0))#VALUE!0#VALUE!#VALUE!=AVERAGE(IFERROR(A2,0),2)#VALUE!1#VALUE!#VALUE!=SUM(IFNA("",0))#VALUE!0#VALUE!#VALUE!=SUM(IFS(TRUE(),""))#VALUE!0#VALUE!#VALUE!=SUM(SWITCH(1,1,""))#VALUE!0#VALUE!#VALUE!=SUM(SWITCH(2,1,0,A2))00#VALUE!0=SUM(IFS(FALSE(),1,TRUE(),A2))00#VALUE!0=SUM(IFNA(NA(),A2))#VALUE!0#VALUE!#VALUE!=SUM(IFERROR(IF(TRUE(),A2),0))#VALUE!0#VALUE!#VALUE!=SUM(IF(TRUE(),IFERROR(A2,0)))#VALUE!0#VALUE!#VALUE!=SUM(IFS(FALSE(),A2,TRUE(),""))#VALUE!0#VALUE!#VALUE!=SUM(SWITCH(2,1,A2,""))#VALUE!0#VALUE!#VALUE!=AVERAGE(IFS(TRUE(),A2),2)21#VALUE!2=AVERAGE(SWITCH(1,1,A2),2)21#VALUE!2=SUM(IFS(TRUE(),B2))0#VALUE!#VALUE!0=SUM(SWITCH(1,1,B2))0#VALUE!#VALUE!0=SUM(SWITCH(1,1,IFS(TRUE(),A2)))00#VALUE!0=MAX(SWITCH(1,1,A2),-1)-10#VALUE!-1=SUM(IFS(TRUE(),C1)),C1holdsTRUE0110=SUM(IFNA(A2,0),5)#VALUE!5#VALUE!#VALUE!=SUM(IFS(FALSE(),"",TRUE(),A2))00#VALUE!0=SUM(SWITCH(1,1,"",A2))#VALUE!0#VALUE!#VALUE!=SUM(CHOOSE(1,A2))00#VALUE!0=MAX(INDEX(A1:A3,2))00#VALUE!0=MIN(INDEX(A1:A3,2))00#VALUE!0=COUNT(INDEX(A1:A3,2))0100=AVERAGE(CHOOSE(1,A2),2)21#VALUE!2=MAX(myName,-1)-10#VALUE!-1=SUM(INDEX(B1:B3,2))0#VALUE!#VALUE!0=SUM(CHOOSE(1,B2))0#VALUE!#VALUE!0=SUM(IF(TRUE(),B2,0))0#VALUE!#VALUE!0=SUM(txtName,5)5#VALUE!#VALUE!5=SUM(A2)0000=SUM((A2))0000=TEXT(A2,"0")"0"#VALUE!#VALUE!=TEXT("","0")"0"#VALUE!#VALUE!=TEXT("abc","0")"abc"#VALUE!#VALUE!#VALUE!=COUNTA((C1)),C1empty0100=COUNTA(C1),C1empty0000=MAXA((D1))0#VALUE!00=MAXA(D1)0000=AVERAGEA((D1),2)1#VALUE!11=AVERAGEA(D1,2)1111=SUMSQ((D1))0#VALUE!00=SUMSQ(D1)0000=COUNTA((A2))1111=COUNTA(A2)1111=MAXA((A2))0000=MAXA(A2)0000=AVERAGEA((A2),2)1111=AVERAGEA(A2,2)1111=""+0#VALUE!0#VALUE!#VALUE!=A2+1#VALUE!1#VALUE!#VALUE!=ROUND(A2,0)#VALUE!0#VALUE!#VALUE!=ABS(A2)#VALUE!0#VALUE!#VALUE!=LN(A2)#VALUE!#NUM!#VALUE!#VALUE!=COUNT("")0100=SUM("")#VALUE!0#VALUE!#VALUE!=AVERAGE("")#VALUE!0#VALUE!#VALUE!=MIN("")#VALUE!0#VALUE!#VALUE!=MAX("")#VALUE!0#VALUE!#VALUE!=PRODUCT("")#VALUE!0#VALUE!#VALUE!=SUM(C1:C3,""),C1:C3holds1,="",2#VALUE!3#VALUE!#VALUE!=SUM(IF(TRUE(),"",1))#VALUE!0#VALUE!#VALUE!=COUNT(IF(TRUE(),"",1))0100=SUM(LEFT("abc",0))#VALUE!0#VALUE!#VALUE!=COUNT(A2)0000=AVERAGE(A2)#DIV/0!#DIV/0!#DIV/0!#DIV/0!=SUM(C1:C3),C1:C3holds1,="",23333=SUM({1,"",2})3333=SUM(IF(G1:G3>0,"",G1:G3))00#VALUE!#VALUE!=COUNT(IF({1,0},"",5))1100=PRODUCT(A2)0111=COUNTIF(C1:C3,""),C1:C3holds1,="",21000=PRODUCT(P1),P1empty,P2holds="",P3holdsabc,P4holds50111=PRODUCT((P1)),P1empty,P2holds="",P3holdsabc,P4holds50011=MEDIAN(P1,1),P1empty,P2holds="",P3holdsabc,P4holds510.50.50.5=PRODUCT(P1,2),P1empty,P2holds="",P3holdsabc,P4holds52222=PRODUCT((P1),2),P1empty,P2holds="",P3holdsabc,P4holds52022=PRODUCT(P2),P1empty,P2holds="",P3holdsabc,P4holds50111=PRODUCT((P2)),P1empty,P2holds="",P3holdsabc,P4holds50011=MEDIAN(P2,1),P1empty,P2holds="",P3holdsabc,P4holds510.5#VALUE!#VALUE!=PRODUCT(P2,2),P1empty,P2holds="",P3holdsabc,P4holds52222=PRODUCT((P2),2),P1empty,P2holds="",P3holdsabc,P4holds52022=MEDIAN((P2),1),P1empty,P2holds="",P3holdsabc,P4holds510.5#VALUE!#VALUE!=PRODUCT(P3),P1empty,P2holds="",P3holdsabc,P4holds50111=PRODUCT((P3)),P1empty,P2holds="",P3holdsabc,P4holds50#VALUE!11=MEDIAN(P3,1),P1empty,P2holds="",P3holdsabc,P4holds51#VALUE!#VALUE!#VALUE!=PRODUCT(P4),P1empty,P2holds="",P3holdsabc,P4holds55555=MEDIAN(P4,1),P1empty,P2holds="",P3holdsabc,P4holds53333=SUM("",2)#VALUE!2#VALUE!#VALUE!=SUM(1,"")#VALUE!1#VALUE!#VALUE!=SUM("",NA())#VALUE!#N/A#VALUE!#VALUE!=SUM(NA(),"")#N/A#N/A#N/A#N/APublic API changes
None: no method, option or type changes, only formula results, as listed above.
Out of scope and follow-ups
TEXTreturns#VALUE!for non-numeric text, now including""; Excel returns the text.=PRODUCT(A2), withA2holding="", returns1; Excel returns0.MEDIANdoes not skip text in a reference:=MEDIAN(P3,1), withP3holdingabc, returns#VALUE!; Excel returns1. With this PR=MEDIAN(P2,1), withP2holding="", does the same; it returned0.5ondevelop.=COUNTIF(C1:C3,"")counts only blank cells, so it returns0; Excel returns1.Types of changes
Related issues
Checklist
dev-docs/pages this change affects – or none needed it.🤖 Generated with Claude Code.