Skip to content

fix: an empty string is no longer coerced to 0 in numeric contexts (HF-361) - #1768

Merged
marcin-kordas-hoc merged 33 commits into
developfrom
fix/hf-361-empty-string-coercion
Nov 19, 2026
Merged

marcin-kordas-hoc merged 33 commits into
developfrom
fix/hf-361-empty-string-coercion

Conversation

@marcin-kordas-hoc

@marcin-kordas-hoc marcin-kordas-hoc commented Sep 10, 2026 •

Copy link
Copy Markdown
Collaborator

Context

The PR stops HyperFormula from reading an empty string ("") as 0 in numeric contexts. The numeric aggregations now read a cell reached through INDEX, CHOOSE, IF, IFS, SWITCH or a named expression like a direct reference to it.

  • Why: in Excel "" is text, so =""+0 returns #VALUE! and =COUNT("") returns 0. develop returns 0 and 1.
  • What changed:
    • 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 an INDEX over one, a named expression defined as one, and an IF, IFS, SWITCH or CHOOSE that returned one.
    • BooleanPlugin.ts: the built-in IF, IFS, SWITCH and CHOOSE record which argument they returned, and clear that record before each evaluation. The aggregation reads the record, so no argument is evaluated twice.
    • IFERROR and IFNA record 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-only IF array in an aggregation. docs/guide/types-of-values.md: empty a cell with null, because '' is stored as text.
    • CHANGELOG.md: two entries under Fixed.
  • Result: of 122 cells measured in Excel, this branch differs on 17. The previous head differs on the same 17 and on 40 more. develop differs on 70.
  • Cost: NumericAggregationPlugin now depends on the built-in BooleanPlugin and InformationPlugin. A custom plugin registered over INDEX, IF, IFS, SWITCH or CHOOSE is read as a value.

How did you test your changes?

  • Paired branch fix/hf-361-empty-string-coercion in hyperformula-tests (hyperformula-tests#53). Against its develop it changes 15 spec files. They are the new empty-string-coercion spec, the SUM, AVERAGE, COUNT, MAX and MIN specs, and the specs whose expected results changed.
  • Two CHOOSEROWS tests from develop used "" 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!.
  • Full Jest run with the paired suite attached: 540 suites, 8448 tests passed, 3 skipped. The SUM, AVERAGE, MAX, MIN, COUNT, empty-string, coercion and CONCAT specs: 245 tests passed. tsc --noEmit and eslint --quiet src: 0 errors.
  • The aggregation change was first measured on its own commit, afb1cfb. On 220 formulas, with error and out-of-range selectors, nested calls, array mode and RAND() in selectors, this head gives the same 220 results. RAND() runs at most once per formula.
  • Against the previous head, 3219161, those 220 formulas show no number turning into an error. A build that evaluates the argument twice on purpose is caught on all 34 RAND() cases.
  • Performance, afb1cfb against 3219161, in 5 alternating pairs at a load below 4:
    • npm run test:performance: every scenario stays within its own spread, with median changes from -5.7% to +0.9%.
    • A micro-benchmark that builds 30,000 rows of IF, CHOOSE and SUM(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.
    • Its best-of-3 times in ms, before and after: 984 and 987, 965 and 1072, 949 and 996, 965 and 1097, 955 and 1003.
    • The same benchmark for IFS and SWITCH is 5.5% slower (median), inside its 10% spread.

AI assistance

Claude Code wrote the changes in ArithmeticHelper, NumericAggregationPlugin and BooleanPlugin, 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:A3 holds 1, ="", 3; B1:B3 holds 1, abc, 3; D1 holds abc; G1:G3 holds 1, 2, 3. myName is =Sheet1!$A$2 and txtName is =Sheet1!$B$2. The PRODUCT and MEDIAN rows use P1 empty, P2 holding ="", P3 holding abc and P4 holding 5.

The 17 differences from Excel are known gaps. PRODUCT with no number (7 rows), MEDIAN with text (4 rows), TEXT over text (3 rows) and COUNTIF with "" (1 row) are follow-ups. The text-only IF array (2 rows) is in the list of differences.

Two of these rows moved away from Excel in this PR: =PRODUCT((P1)) and =PRODUCT((P2)) returned 0 on develop, as in Excel, and now return 1, like =PRODUCT(P1). A parenthesized reference is now read like the bare reference.

All 107 formulas measured in Excel and replayed on each head
Formula Excel Google Sheets develop #1768 before (3219161) #1768 now (aff4073)
=SUM(IF(TRUE(),A2,"")) 0 not checked 0 #VALUE! 0
=SUM(IF(TRUE(),A2)) 0 not checked 0 #VALUE! 0
=SUM(CHOOSE(1,A2,"")) 0 not checked 0 #VALUE! 0
=SUM(INDEX(A1:A3,2)) 0 not checked 0 #VALUE! 0
=AVERAGE(INDEX(A1:A3,2),2) 2 not checked 1 #VALUE! 2
=SUM(IF(TRUE(),A2,0)) 0 not checked 0 #VALUE! 0
=SUM(A1:A3) 4 not checked 4 4 4
=SUM(myName,5) 5 not checked 5 #VALUE! 5
=SUM(IFERROR(A2,0)) #VALUE! not checked 0 #VALUE! #VALUE!
=SUM(IFNA(A2,0)) #VALUE! not checked 0 #VALUE! #VALUE!
=SUM(IFS(TRUE(),A2)) 0 not checked 0 #VALUE! 0
=SUM(SWITCH(1,1,A2)) 0 not checked 0 #VALUE! 0
=SUM(IFERROR(1/0,A2)) #VALUE! not checked 0 #VALUE! #VALUE!
=SUM(IFERROR("",0)) #VALUE! not checked 0 #VALUE! #VALUE!
=AVERAGE(IFERROR(A2,0),2) #VALUE! not checked 1 #VALUE! #VALUE!
=SUM(IFNA("",0)) #VALUE! not checked 0 #VALUE! #VALUE!
=SUM(IFS(TRUE(),"")) #VALUE! not checked 0 #VALUE! #VALUE!
=SUM(SWITCH(1,1,"")) #VALUE! not checked 0 #VALUE! #VALUE!
=SUM(SWITCH(2,1,0,A2)) 0 not checked 0 #VALUE! 0
=SUM(IFS(FALSE(),1,TRUE(),A2)) 0 not checked 0 #VALUE! 0
=SUM(IFNA(NA(),A2)) #VALUE! not checked 0 #VALUE! #VALUE!
=SUM(IFERROR(IF(TRUE(),A2),0)) #VALUE! not checked 0 #VALUE! #VALUE!
=SUM(IF(TRUE(),IFERROR(A2,0))) #VALUE! not checked 0 #VALUE! #VALUE!
=SUM(IFS(FALSE(),A2,TRUE(),"")) #VALUE! not checked 0 #VALUE! #VALUE!
=SUM(SWITCH(2,1,A2,"")) #VALUE! not checked 0 #VALUE! #VALUE!
=AVERAGE(IFS(TRUE(),A2),2) 2 not checked 1 #VALUE! 2
=AVERAGE(SWITCH(1,1,A2),2) 2 not checked 1 #VALUE! 2
=SUM(IFS(TRUE(),B2)) 0 not checked #VALUE! #VALUE! 0
=SUM(SWITCH(1,1,B2)) 0 not checked #VALUE! #VALUE! 0
=SUM(SWITCH(1,1,IFS(TRUE(),A2))) 0 not checked 0 #VALUE! 0
=MAX(SWITCH(1,1,A2),-1) -1 not checked 0 #VALUE! -1
=SUM(IFS(TRUE(),C1)), C1 holds TRUE 0 not checked 1 1 0
=SUM(IFNA(A2,0),5) #VALUE! not checked 5 #VALUE! #VALUE!
=SUM(IFS(FALSE(),"",TRUE(),A2)) 0 not checked 0 #VALUE! 0
=SUM(SWITCH(1,1,"",A2)) #VALUE! not checked 0 #VALUE! #VALUE!
=SUM(CHOOSE(1,A2)) 0 not checked 0 #VALUE! 0
=MAX(INDEX(A1:A3,2)) 0 not checked 0 #VALUE! 0
=MIN(INDEX(A1:A3,2)) 0 not checked 0 #VALUE! 0
=COUNT(INDEX(A1:A3,2)) 0 not checked 1 0 0
=AVERAGE(CHOOSE(1,A2),2) 2 not checked 1 #VALUE! 2
=MAX(myName,-1) -1 not checked 0 #VALUE! -1
=SUM(INDEX(B1:B3,2)) 0 not checked #VALUE! #VALUE! 0
=SUM(CHOOSE(1,B2)) 0 not checked #VALUE! #VALUE! 0
=SUM(IF(TRUE(),B2,0)) 0 not checked #VALUE! #VALUE! 0
=SUM(txtName,5) 5 not checked #VALUE! #VALUE! 5
=SUM(A2) 0 not checked 0 0 0
=SUM((A2)) 0 not checked 0 0 0
=TEXT(A2,"0") empty text not checked "0" #VALUE! #VALUE!
=TEXT("","0") empty text not checked "0" #VALUE! #VALUE!
=TEXT("abc","0") "abc" not checked #VALUE! #VALUE! #VALUE!
=COUNTA((C1)), C1 empty 0 not checked 1 0 0
=COUNTA(C1), C1 empty 0 not checked 0 0 0
=MAXA((D1)) 0 not checked #VALUE! 0 0
=MAXA(D1) 0 not checked 0 0 0
=AVERAGEA((D1),2) 1 not checked #VALUE! 1 1
=AVERAGEA(D1,2) 1 not checked 1 1 1
=SUMSQ((D1)) 0 not checked #VALUE! 0 0
=SUMSQ(D1) 0 not checked 0 0 0
=COUNTA((A2)) 1 not checked 1 1 1
=COUNTA(A2) 1 not checked 1 1 1
=MAXA((A2)) 0 not checked 0 0 0
=MAXA(A2) 0 not checked 0 0 0
=AVERAGEA((A2),2) 1 not checked 1 1 1
=AVERAGEA(A2,2) 1 not checked 1 1 1
=""+0 #VALUE! not checked 0 #VALUE! #VALUE!
=A2+1 #VALUE! not checked 1 #VALUE! #VALUE!
=ROUND(A2,0) #VALUE! not checked 0 #VALUE! #VALUE!
=ABS(A2) #VALUE! not checked 0 #VALUE! #VALUE!
=LN(A2) #VALUE! not checked #NUM! #VALUE! #VALUE!
=COUNT("") 0 not checked 1 0 0
=SUM("") #VALUE! not checked 0 #VALUE! #VALUE!
=AVERAGE("") #VALUE! not checked 0 #VALUE! #VALUE!
=MIN("") #VALUE! not checked 0 #VALUE! #VALUE!
=MAX("") #VALUE! not checked 0 #VALUE! #VALUE!
=PRODUCT("") #VALUE! not checked 0 #VALUE! #VALUE!
=SUM(C1:C3,""), C1:C3 holds 1, ="", 2 #VALUE! not checked 3 #VALUE! #VALUE!
=SUM(IF(TRUE(),"",1)) #VALUE! not checked 0 #VALUE! #VALUE!
=COUNT(IF(TRUE(),"",1)) 0 not checked 1 0 0
=SUM(LEFT("abc",0)) #VALUE! not checked 0 #VALUE! #VALUE!
=COUNT(A2) 0 not checked 0 0 0
=AVERAGE(A2) #DIV/0! not checked #DIV/0! #DIV/0! #DIV/0!
=SUM(C1:C3), C1:C3 holds 1, ="", 2 3 not checked 3 3 3
=SUM({1,"",2}) 3 not checked 3 3 3
=SUM(IF(G1:G3>0,"",G1:G3)) 0 not checked 0 #VALUE! #VALUE!
=COUNT(IF({1,0},"",5)) 1 not checked 1 0 0
=PRODUCT(A2) 0 not checked 1 1 1
=COUNTIF(C1:C3,""), C1:C3 holds 1, ="", 2 1 not checked 0 0 0
=PRODUCT(P1), P1 empty, P2 holds ="", P3 holds abc, P4 holds 5 0 not checked 1 1 1
=PRODUCT((P1)), P1 empty, P2 holds ="", P3 holds abc, P4 holds 5 0 not checked 0 1 1
=MEDIAN(P1,1), P1 empty, P2 holds ="", P3 holds abc, P4 holds 5 1 not checked 0.5 0.5 0.5
=PRODUCT(P1,2), P1 empty, P2 holds ="", P3 holds abc, P4 holds 5 2 not checked 2 2 2
=PRODUCT((P1),2), P1 empty, P2 holds ="", P3 holds abc, P4 holds 5 2 not checked 0 2 2
=PRODUCT(P2), P1 empty, P2 holds ="", P3 holds abc, P4 holds 5 0 not checked 1 1 1
=PRODUCT((P2)), P1 empty, P2 holds ="", P3 holds abc, P4 holds 5 0 not checked 0 1 1
=MEDIAN(P2,1), P1 empty, P2 holds ="", P3 holds abc, P4 holds 5 1 not checked 0.5 #VALUE! #VALUE!
=PRODUCT(P2,2), P1 empty, P2 holds ="", P3 holds abc, P4 holds 5 2 not checked 2 2 2
=PRODUCT((P2),2), P1 empty, P2 holds ="", P3 holds abc, P4 holds 5 2 not checked 0 2 2
=MEDIAN((P2),1), P1 empty, P2 holds ="", P3 holds abc, P4 holds 5 1 not checked 0.5 #VALUE! #VALUE!
=PRODUCT(P3), P1 empty, P2 holds ="", P3 holds abc, P4 holds 5 0 not checked 1 1 1
=PRODUCT((P3)), P1 empty, P2 holds ="", P3 holds abc, P4 holds 5 0 not checked #VALUE! 1 1
=MEDIAN(P3,1), P1 empty, P2 holds ="", P3 holds abc, P4 holds 5 1 not checked #VALUE! #VALUE! #VALUE!
=PRODUCT(P4), P1 empty, P2 holds ="", P3 holds abc, P4 holds 5 5 not checked 5 5 5
=MEDIAN(P4,1), P1 empty, P2 holds ="", P3 holds abc, P4 holds 5 3 not checked 3 3 3
=SUM("",2) #VALUE! not checked 2 #VALUE! #VALUE!
=SUM(1,"") #VALUE! not checked 1 #VALUE! #VALUE!
=SUM("",NA()) #VALUE! not checked #N/A #VALUE! #VALUE!
=SUM(NA(),"") #N/A not checked #N/A #N/A #N/A

Public API changes

None: no method, option or type changes, only formula results, as listed above.

Out of scope and follow-ups

  • TEXT returns #VALUE! for non-numeric text, now including ""; Excel returns the text.
  • =PRODUCT(A2), with A2 holding ="", returns 1; Excel returns 0.
  • MEDIAN does not skip text in a reference: =MEDIAN(P3,1), with P3 holding abc, returns #VALUE!; Excel returns 1. With this PR =MEDIAN(P2,1), with P2 holding ="", does the same; it returned 0.5 on develop.
  • =COUNTIF(C1:C3,"") counts only blank cells, so it returns 0; Excel returns 1.

Types of changes

  • Breaking change (existing functionality no longer works as before) – agreed with the maintainers
  • New feature or improvement (a non-breaking change that adds functionality)
  • Bug fix (a non-breaking change that fixes an issue)
  • Additional language file, or a change to an existing language file (translations)
  • Change to the documentation

Related issues

  1. HF-361.

Checklist

🤖 Generated with Claude Code.

`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>
@qunabu

qunabu commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

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>
@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Performance comparison of head (f494586) vs base (9ea6b41)

                                     testName |    base |    head |  change
---------------------------------------------------------------------------
                                      Sheet A |  517.45 |  495.45 |  -4.25%
                                      Sheet B |  163.22 |  162.87 |  -0.21%
                                      Sheet T |  148.61 |  143.57 |  -3.39%
                                Column ranges |  484.55 |  481.46 |  -0.64%
                                Sorted lookup | 15446.4 | 14906.2 |  -3.50%
Sheet A:  change value, add/remove row/column |   17.14 |   17.52 |  +2.22%
 Sheet B: change value, add/remove row/column |  136.42 |  137.15 |  +0.54%
                   Column ranges - add column |  164.14 |  184.08 | +12.15%
                Column ranges - without batch |  463.93 |  496.32 |  +6.98%
                        Column ranges - batch |   108.9 |  119.01 |  +9.28%

…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>
@marcin-kordas-hoc
marcin-kordas-hoc marked this pull request as ready for review September 10, 2026 15:37

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread docs/guide/migration-from-3.x-to-4.0.md Resolved

@Tobiadefami Tobiadefami left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@marcin-kordas-hoc

Copy link
Copy Markdown
Collaborator Author

@Tobiadefami reproduced and fixed — thanks for catching it, and sorry it sat this long.

SUM((B1)) was going through the same numeric-coercion path a literal gets, because (B1) reaches NumericAggregationPlugin#reduce as a PARENTHESIS AST node wrapping the CELL_REFERENCE, and the reducer's reference check only matched a bare CELL_REFERENCE node. Fixed by unwrapping PARENTHESIS before that check — the same pattern already used in FunctionPlugin#runFunctionWithReferenceArgument and InformationPlugin — so it's a one-line fix at a single shared choke point rather than a per-function patch.

That choke point (reduce()) is the shared implementation behind the whole numeric-aggregation family, not just SUM: COUNT, AVERAGE, MIN, MAX, PRODUCT, SUMSQ, STDEV.S/P (and their A-suffixed variants) all reproduced the identical #VALUE! regression through one extra pair of parentheses, and all are fixed by this single change. MIN/MAX weren't in your report but I checked them too since they share reduce() — same bug, same fix.

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 "". Your reading was exactly right.

Added 8 specs to the paired repo (empty-string-coercion.spec.ts), written and confirmed failing against the previous head before the fix existed, passing after, and reconfirmed failing with the source fix reverted and the tests kept (negative control). Local Jest: 503/503 suites, 6279 passing.

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 a24a523dd; please treat the browser result there as the real verdict, not my local run.

MEDIAN does not share this bug (different code path, no reference-detection special case at all) — flagging separately rather than folding it in here.

@marcin-kordas-hoc

Copy link
Copy Markdown
Collaborator Author

DROP and TAKE (open in #1796 and #1722) depend on this change too. On the #1796 head an empty-string count gives DROP(A1:C3,"") the whole array and TAKE(A1:C3,"") #N/A. With this PR's src/ change applied on top, both return #VALUE! for row and column counts, which matches Excel Online. Whichever of the three merges last should add those cases to its specs.

marcin-kordas-hoc and others added 2 commits October 22, 2026 17:31
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@marcin-kordas-hoc

Copy link
Copy Markdown
Collaborator Author

Fixed in a24a523, along the lines you suggested: NumericAggregationPlugin.reduce() now looks through parentheses before deciding whether an argument is a reference. With B1 holding ="", =SUM((B1)) returns 0 again, and so do COUNT, MIN and MAX, while AVERAGE returns #DIV/0!. Nested parentheses and parenthesized ranges behave the same. The cases are pinned in hyperformula-tests#53 (empty-string-coercion.spec.ts).

The branch is now up to date with develop. Could you take another look?

marcin-kordas-hoc and others added 3 commits October 23, 2026 00:29
…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>
marcin-kordas-hoc and others added 4 commits October 30, 2026 03:41
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>
@marcin-kordas-hoc

Copy link
Copy Markdown
Collaborator Author

The decision on HF-361 is to ship this as a bug fix in the upcoming release, not as a breaking change: 8bc9db8 moves the entry to Fixed and removes the migration guide. d476660 adds one sentence to the types-of-values guide instead: to empty a cell, pass null, not ''.

# Conflicts:
#	CHANGELOG.md
#	docs/guide/list-of-differences.md
…ifferences from Excel

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@marcin-kordas-hoc

Copy link
Copy Markdown
Collaborator Author

The INDEX, CHOOSE, IF and named-expression cases are now a row in the list of differences, added in 3219161, and a table in the description. Excel Online returns 0 for the first three and 5 for =SUM(myName,5). TEXT has its own table: Excel returns empty text for =TEXT(A2,"0") and =TEXT("","0"), where HyperFormula now returns #VALUE!. Both engine fixes are listed under follow-ups. The description has an AI assistance section now, and so does hyperformula-tests#53.

marcin-kordas-hoc and others added 7 commits November 15, 2026 20:55
…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>

@handsontable-pr-review handsontable-pr-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Tobiadefami left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

marcin-kordas-hoc and others added 2 commits November 19, 2026 09:54
… 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>
@marcin-kordas-hoc
marcin-kordas-hoc enabled auto-merge (squash) November 19, 2026 10:23

@handsontable-pr-review handsontable-pr-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Tobiadefami left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@codecov

codecov Bot commented Nov 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.61%. Comparing base (62e8539) to head (f494586).
⚠️ Report is 12 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             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     
Files with missing lines Coverage Δ
hyperformula/src/interpreter/ArithmeticHelper.ts 98.67% <ø> (-0.01%) ⬇️
...performula/src/interpreter/plugin/BooleanPlugin.ts 100.00% <100.00%> (ø)
...yperformula/src/interpreter/plugin/LookupPlugin.ts 97.45% <100.00%> (+0.19%) ⬆️
...src/interpreter/plugin/NumericAggregationPlugin.ts 97.68% <100.00%> (+0.44%) ⬆️
...formula/src/interpreter/plugin/SelectedArgument.ts 100.00% <100.00%> (ø)

... and 8 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@marcin-kordas-hoc
marcin-kordas-hoc merged commit b29982e into develop Nov 19, 2026
38 checks passed
@marcin-kordas-hoc
marcin-kordas-hoc deleted the fix/hf-361-empty-string-coercion branch November 19, 2026 18:11
marcin-kordas-hoc added a commit that referenced this pull request Nov 23, 2026
…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>
marcin-kordas-hoc added a commit that referenced this pull request Nov 26, 2026
### 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants