From 1f28cdb05fbfc91aac133784943c1fa0ebc886d0 Mon Sep 17 00:00:00 2001 From: marcin-kordas-hoc Date: Tue, 6 Oct 2026 08:59:09 +0000 Subject: [PATCH 01/12] Fix the accuracy of ERF and ERFC near zero and in the tail erf is computed from its series below 2 and from the continued fraction of erfc above, instead of 1 - exp(...), which lost every digit below about 1e-16. erfc uses the continued fraction from 1 upwards. Relative error against Python's math.erf and math.erfc is at most 7e-16 for erf and 2e-16 for erfc. Co-Authored-By: Claude Sonnet 5.5 --- CHANGELOG.md | 1 + .../plugin/3rdparty/jstat/jstat.ts | 87 ++++++++++++------- 2 files changed, 55 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f97c660139..c7f136d567 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Fixed - Fixed the validation of classic (25-character) license keys depending on the time zone: east of UTC, a key that expired the day before the build was released was still accepted, and west of UTC, the console message printed an expiry date one day too early. [#1728](https://github.com/handsontable/hyperformula/pull/1728) +- Fixed the `ERF` and `ERFC` functions (and the normal and log-normal distributions that use them) losing precision for arguments close to zero and for large arguments, for example `ERF(1E-10)` and `ERFC(5)`; the results now agree with Excel. - Fixed the `AVERAGEIF` function returning a division-by-zero error when the calculated average was `0`. [#1733](https://github.com/handsontable/hyperformula/pull/1733) - Fixed the localized names of `VSTACK` and `HSTACK` in 14 language packs to match Microsoft Excel. [#1748](https://github.com/handsontable/hyperformula/pull/1748) - Fixed the `MAXPOOL` and `MEDIANPOOL` functions throwing an uncaught `TypeError` or `RangeError`. They now return the `#VALUE!` error when the window is larger than the range or the range dimensions, reduced by the window size, are not whole multiples of the stride, and the `#NUM!` error when the window size or the stride is not a positive integer. [#1718](https://github.com/handsontable/hyperformula/pull/1718) diff --git a/src/interpreter/plugin/3rdparty/jstat/jstat.ts b/src/interpreter/plugin/3rdparty/jstat/jstat.ts index 94e10c8dd5..caff10708f 100644 --- a/src/interpreter/plugin/3rdparty/jstat/jstat.ts +++ b/src/interpreter/plugin/3rdparty/jstat/jstat.ts @@ -21,46 +21,67 @@ THE SOFTWARE. */ -export function erf(x: number): number { - const cof = [-1.3026537197817094, 6.4196979235649026e-1, 1.9476473204185836e-2, - -9.561514786808631e-3, -9.46595344482036e-4, 3.66839497852761e-4, - 4.2523324806907e-5, -2.0278578112534e-5, -1.624290004647e-6, - 1.303655835580e-6, 1.5626441722e-8, -8.5238095915e-8, - 6.529054439e-9, 5.059343495e-9, -9.91364156e-10, - -2.27365122e-10, 9.6467911e-11, 2.394038e-12, - -6.886027e-12, 8.94487e-13, 3.13092e-13, - -1.12708e-13, 3.81e-16, 7.106e-15, - -1.523e-15, -9.4e-17, 1.21e-16, - -2.8e-17] - let j = cof.length - 1 - let isneg = false - let d = 0 - let dd = 0 - let t, ty, tmp, res - - if (x === 0) { - return 0 - } - if (x < 0) { - x = -x - isneg = true - } +const SQRT_PI = Math.sqrt(Math.PI) - t = 2 / (2 + x) - ty = 4 * t - 2 +/** + * erf(x) for 0 <= x < 2 from its series exp(-x^2) * 2 / sqrt(pi) * sum(2^n * x^(2n + 1) / (2n + 1)!!). + * All terms are positive, so there is no cancellation, and the relative error stays near 1e-16 down to the + * smallest numbers (the earlier 1 - exp(...) form lost every digit below about 1e-16). + */ +function erfSeries(x: number): number { + const xx = x * x + let term = x + let sum = x + for (let n = 0; n < 500; n++) { + term *= 2 * xx / (2 * n + 3) + sum += term + if (term < sum * 1e-17) { + break + } + } + return 2 / SQRT_PI * Math.exp(-xx) * sum +} - for (; j > 0; j--) { - tmp = d - d = ty * d - dd + cof[j] - dd = tmp +/** + * erfc(x) for x >= 1 from the continued fraction exp(-x^2) / sqrt(pi) / (x + (1/2) / (x + 1 / (x + (3/2) / (x + ...)))), + * evaluated from the tail. Accurate to about 1e-16 relative, also where erfc is tiny and 1 - erf(x) would be 0. + */ +function erfcFraction(x: number): number { + let tail = 0 + for (let k = 300; k >= 1; k--) { + tail = (k / 2) / (x + tail) } + return Math.exp(-x * x) / SQRT_PI / (x + tail) +} - res = t * Math.exp(-x * x + 0.5 * (cof[0] + ty * d) - dd) - return isneg ? res - 1 : 1 - res +export function erf(x: number): number { + if (x === 0 || Number.isNaN(x)) { + return x + } + const abs = Math.abs(x) + let result + if (abs < 2) { + result = erfSeries(abs) + } else if (abs < 6.5) { + result = 1 - erfcFraction(abs) + } else { + result = 1 + } + return x < 0 ? -result : result } export function erfc(x: number): number { - return 1 - erf(x) + if (Number.isNaN(x)) { + return x + } + if (x < 0) { + return 2 - erfc(-x) + } + if (x < 1) { + return 1 - erfSeries(x) + } + // erfc(27.3) is below the smallest double + return x < 27.3 ? erfcFraction(x) : 0 } function erfcinv(p: number): number { From 86e35df03e3896412b30558ff20aedb551acf686 Mon Sep 17 00:00:00 2001 From: marcin-kordas-hoc Date: Tue, 6 Oct 2026 08:59:47 +0000 Subject: [PATCH 02/12] docs: link the PR in the CHANGELOG entry Co-Authored-By: Claude Sonnet 5.5 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7f136d567..ebe1a6dc32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Fixed - Fixed the validation of classic (25-character) license keys depending on the time zone: east of UTC, a key that expired the day before the build was released was still accepted, and west of UTC, the console message printed an expiry date one day too early. [#1728](https://github.com/handsontable/hyperformula/pull/1728) -- Fixed the `ERF` and `ERFC` functions (and the normal and log-normal distributions that use them) losing precision for arguments close to zero and for large arguments, for example `ERF(1E-10)` and `ERFC(5)`; the results now agree with Excel. +- Fixed the `ERF` and `ERFC` functions (and the normal and log-normal distributions that use them) losing precision for arguments close to zero and for large arguments, for example `ERF(1E-10)` and `ERFC(5)`; the results now agree with Excel. [#1795](https://github.com/handsontable/hyperformula/pull/1795) - Fixed the `AVERAGEIF` function returning a division-by-zero error when the calculated average was `0`. [#1733](https://github.com/handsontable/hyperformula/pull/1733) - Fixed the localized names of `VSTACK` and `HSTACK` in 14 language packs to match Microsoft Excel. [#1748](https://github.com/handsontable/hyperformula/pull/1748) - Fixed the `MAXPOOL` and `MEDIANPOOL` functions throwing an uncaught `TypeError` or `RangeError`. They now return the `#VALUE!` error when the window is larger than the range or the range dimensions, reduced by the window size, are not whole multiples of the stride, and the `#NUM!` error when the window size or the stride is not a positive integer. [#1718](https://github.com/handsontable/hyperformula/pull/1718) From 986b0a3a4f8816205175ddc7ce21d6d2766f1c9a Mon Sep 17 00:00:00 2001 From: marcin-kordas-hoc Date: Wed, 7 Oct 2026 06:21:57 +0000 Subject: [PATCH 03/12] chore: re-run CI against updated tests Co-Authored-By: Claude Sonnet 5.5 From ec4130fe43af388ed70f6565f5bac7e8d85e900a Mon Sep 17 00:00:00 2001 From: marcin-kordas-hoc Date: Thu, 8 Oct 2026 01:56:01 +0000 Subject: [PATCH 04/12] docs: drop the unverified distribution accuracy claim from the changelog Co-Authored-By: Claude Sonnet 5.5 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ebe1a6dc32..12cb49c996 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Fixed - Fixed the validation of classic (25-character) license keys depending on the time zone: east of UTC, a key that expired the day before the build was released was still accepted, and west of UTC, the console message printed an expiry date one day too early. [#1728](https://github.com/handsontable/hyperformula/pull/1728) -- Fixed the `ERF` and `ERFC` functions (and the normal and log-normal distributions that use them) losing precision for arguments close to zero and for large arguments, for example `ERF(1E-10)` and `ERFC(5)`; the results now agree with Excel. [#1795](https://github.com/handsontable/hyperformula/pull/1795) +- Fixed the `ERF` and `ERFC` functions losing precision for arguments close to zero and for large arguments, for example `ERF(1E-10)` and `ERFC(5)`; the results now agree with Excel. [#1795](https://github.com/handsontable/hyperformula/pull/1795) - Fixed the `AVERAGEIF` function returning a division-by-zero error when the calculated average was `0`. [#1733](https://github.com/handsontable/hyperformula/pull/1733) - Fixed the localized names of `VSTACK` and `HSTACK` in 14 language packs to match Microsoft Excel. [#1748](https://github.com/handsontable/hyperformula/pull/1748) - Fixed the `MAXPOOL` and `MEDIANPOOL` functions throwing an uncaught `TypeError` or `RangeError`. They now return the `#VALUE!` error when the window is larger than the range or the range dimensions, reduced by the window size, are not whole multiples of the stride, and the `#NUM!` error when the window size or the stride is not a positive integer. [#1718](https://github.com/handsontable/hyperformula/pull/1718) From 329b98d24134b96ad5d4e35a7303eca0a7d9a2d1 Mon Sep 17 00:00:00 2001 From: marcin-kordas-hoc Date: Thu, 8 Oct 2026 03:43:28 +0000 Subject: [PATCH 05/12] chore: re-run CI Co-Authored-By: Claude Sonnet 5.5 From d0d46b707b0d84bcad009661b8909a3456a1b6b8 Mon Sep 17 00:00:00 2001 From: marcin-kordas-hoc Date: Mon, 12 Oct 2026 03:46:03 +0000 Subject: [PATCH 06/12] docs: place the changelog entry under Unreleased Co-Authored-By: Claude Sonnet 5.5 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12cb49c996..2f0f5e38b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Fixed - Fixed the `EDATE` function returning the 28th of February instead of the 29th when the shifted date falls in February of a leap year (e.g. `=EDATE(DATE(2028, 1, 31), 1)` now returns `2028-02-29` instead of `2028-02-28`). [#1781](https://github.com/handsontable/hyperformula/pull/1781) +- Fixed the `ERF` and `ERFC` functions losing precision for arguments close to zero and for large arguments, for example `ERF(1E-10)` and `ERFC(5)`; the results now agree with Excel. [#1795](https://github.com/handsontable/hyperformula/pull/1795) ## [3.5.0] - 2026-10-09 @@ -26,7 +27,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Fixed - Fixed the validation of classic (25-character) license keys depending on the time zone: east of UTC, a key that expired the day before the build was released was still accepted, and west of UTC, the console message printed an expiry date one day too early. [#1728](https://github.com/handsontable/hyperformula/pull/1728) -- Fixed the `ERF` and `ERFC` functions losing precision for arguments close to zero and for large arguments, for example `ERF(1E-10)` and `ERFC(5)`; the results now agree with Excel. [#1795](https://github.com/handsontable/hyperformula/pull/1795) - Fixed the `AVERAGEIF` function returning a division-by-zero error when the calculated average was `0`. [#1733](https://github.com/handsontable/hyperformula/pull/1733) - Fixed the localized names of `VSTACK` and `HSTACK` in 14 language packs to match Microsoft Excel. [#1748](https://github.com/handsontable/hyperformula/pull/1748) - Fixed the `MAXPOOL` and `MEDIANPOOL` functions throwing an uncaught `TypeError` or `RangeError`. They now return the `#VALUE!` error when the window is larger than the range or the range dimensions, reduced by the window size, are not whole multiples of the stride, and the `#NUM!` error when the window size or the stride is not a positive integer. [#1718](https://github.com/handsontable/hyperformula/pull/1718) From edadab459aa25b0ab2d549968cdcdd65de6cb723 Mon Sep 17 00:00:00 2001 From: marcin-kordas-hoc Date: Thu, 15 Oct 2026 02:12:44 +0000 Subject: [PATCH 07/12] Mention the corrected inverse normal functions in the changelog Co-Authored-By: Claude Sonnet 5.5 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f0f5e38b3..1d0a0b1786 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Fixed - Fixed the `EDATE` function returning the 28th of February instead of the 29th when the shifted date falls in February of a leap year (e.g. `=EDATE(DATE(2028, 1, 31), 1)` now returns `2028-02-29` instead of `2028-02-28`). [#1781](https://github.com/handsontable/hyperformula/pull/1781) -- Fixed the `ERF` and `ERFC` functions losing precision for arguments close to zero and for large arguments, for example `ERF(1E-10)` and `ERFC(5)`; the results now agree with Excel. [#1795](https://github.com/handsontable/hyperformula/pull/1795) +- Fixed the `ERF` and `ERFC` functions losing precision near zero and for large arguments, which also corrected `NORM.INV`, `NORM.S.INV` and `LOGNORM.INV` in the tails, e.g. `NORM.S.INV(1e-20)`. [#1795](https://github.com/handsontable/hyperformula/pull/1795) ## [3.5.0] - 2026-10-09 From 4cb4559cbd65c671850d1c84f5c1730f34053681 Mon Sep 17 00:00:00 2001 From: marcin-kordas-hoc Date: Thu, 22 Oct 2026 15:16:53 +0000 Subject: [PATCH 08/12] HF-482: State the measured accuracy of the erf series and the erfc continued fraction Co-Authored-By: Claude Opus 5.5 --- hyperformula/src/interpreter/plugin/3rdparty/jstat/jstat.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hyperformula/src/interpreter/plugin/3rdparty/jstat/jstat.ts b/hyperformula/src/interpreter/plugin/3rdparty/jstat/jstat.ts index caff10708f..f05fdb7db8 100644 --- a/hyperformula/src/interpreter/plugin/3rdparty/jstat/jstat.ts +++ b/hyperformula/src/interpreter/plugin/3rdparty/jstat/jstat.ts @@ -25,7 +25,7 @@ const SQRT_PI = Math.sqrt(Math.PI) /** * erf(x) for 0 <= x < 2 from its series exp(-x^2) * 2 / sqrt(pi) * sum(2^n * x^(2n + 1) / (2n + 1)!!). - * All terms are positive, so there is no cancellation, and the relative error stays near 1e-16 down to the + * All terms are positive, so there is no cancellation, and the relative error stays below about 1.1e-15 down to the * smallest numbers (the earlier 1 - exp(...) form lost every digit below about 1e-16). */ function erfSeries(x: number): number { @@ -44,7 +44,9 @@ function erfSeries(x: number): number { /** * erfc(x) for x >= 1 from the continued fraction exp(-x^2) / sqrt(pi) / (x + (1/2) / (x + 1 / (x + (3/2) / (x + ...)))), - * evaluated from the tail. Accurate to about 1e-16 relative, also where erfc is tiny and 1 - erf(x) would be 0. + * evaluated from the tail. The relative error is below about 4e-15 up to x = 6.5 and grows with x^2 beyond that, + * to about 6e-14 near x = 24, because x * x is rounded before exp(-x * x). It stays accurate where erfc is tiny + * and 1 - erf(x) would be 0. */ function erfcFraction(x: number): number { let tail = 0 From b05689e718ef902ab24a4d9ba534f55df1f78b65 Mon Sep 17 00:00:00 2001 From: marcin-kordas-hoc Date: Thu, 5 Nov 2026 06:01:25 +0000 Subject: [PATCH 09/12] Return 0 from ERFC for a result below the smallest normal double From about x = 26.55 the continued fraction gives a subnormal double, which Excel Online returns as 0 (=ERFC(26.54) is 2.64555817446854E-308, =ERFC(26.55) is 0). Co-Authored-By: Claude Opus 5.5 --- .../src/interpreter/plugin/3rdparty/jstat/jstat.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hyperformula/src/interpreter/plugin/3rdparty/jstat/jstat.ts b/hyperformula/src/interpreter/plugin/3rdparty/jstat/jstat.ts index f05fdb7db8..03df24586b 100644 --- a/hyperformula/src/interpreter/plugin/3rdparty/jstat/jstat.ts +++ b/hyperformula/src/interpreter/plugin/3rdparty/jstat/jstat.ts @@ -23,6 +23,11 @@ const SQRT_PI = Math.sqrt(Math.PI) +/** + * 2^-1022, the smallest positive double with full precision; smaller ones are subnormal. + */ +const SMALLEST_NORMAL_DOUBLE = 2.2250738585072014e-308 + /** * erf(x) for 0 <= x < 2 from its series exp(-x^2) * 2 / sqrt(pi) * sum(2^n * x^(2n + 1) / (2n + 1)!!). * All terms are positive, so there is no cancellation, and the relative error stays below about 1.1e-15 down to the @@ -83,7 +88,9 @@ export function erfc(x: number): number { return 1 - erfSeries(x) } // erfc(27.3) is below the smallest double - return x < 27.3 ? erfcFraction(x) : 0 + const result = x < 27.3 ? erfcFraction(x) : 0 + // A result below the smallest normal double (from about x = 26.55) is returned as 0 + return result < SMALLEST_NORMAL_DOUBLE ? 0 : result } function erfcinv(p: number): number { From f12f6938c12d5f3549d251fa00634210f3fc394d Mon Sep 17 00:00:00 2001 From: marcin-kordas-hoc Date: Tue, 10 Nov 2026 07:43:39 +0000 Subject: [PATCH 10/12] Show the NORM.S.INV change in the ERF/ERFC changelog entry The entry now says which function changed where (ERF near zero, ERFC for large arguments) and gives the NORM.S.INV(1e-20) result before and after. The erfSeries comment no longer describes the code it replaced. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 2 +- hyperformula/src/interpreter/plugin/3rdparty/jstat/jstat.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8334d70136..c38e6a49b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Fixed the `EDATE` function returning the 28th of February instead of the 29th when the shifted date falls in February of a leap year (e.g. `=EDATE(DATE(2028, 1, 31), 1)` now returns `2028-02-29` instead of `2028-02-28`). [#1781](https://github.com/handsontable/hyperformula/pull/1781) - Fixed `getCellValue()`, `getSheetValues()` and the other methods that export cell values ignoring the `evaluateNullToZero` option: with the option on, they now return `0` for empty cells instead of `null`. [#1738](https://github.com/handsontable/hyperformula/pull/1738) - Fixed approximate `XLOOKUP` ignoring values of a different type in some search modes, and approximate `MATCH`, `VLOOKUP`, and `HLOOKUP` taking such values into account for non-range arrays, single-cell ranges, and binary search over sorted cell ranges; both now behave the same in linear and binary search, consistent with Microsoft Excel. [#1755](https://github.com/handsontable/hyperformula/pull/1755) -- Fixed the `ERF` and `ERFC` functions losing precision near zero and for large arguments, which also corrected `NORM.INV`, `NORM.S.INV` and `LOGNORM.INV` in the tails, e.g. `NORM.S.INV(1e-20)`. [#1795](https://github.com/handsontable/hyperformula/pull/1795) +- Fixed the `ERF` function losing precision near zero and the `ERFC` function losing it for large arguments, which also corrected `NORM.INV`, `NORM.S.INV` and `LOGNORM.INV` in the tails (e.g. `=NORM.S.INV(1e-20)` now returns `-9.2623400898` instead of `-9.1468519416`). [#1795](https://github.com/handsontable/hyperformula/pull/1795) ## [3.5.0] - 2026-10-09 diff --git a/hyperformula/src/interpreter/plugin/3rdparty/jstat/jstat.ts b/hyperformula/src/interpreter/plugin/3rdparty/jstat/jstat.ts index 03df24586b..f3aee1dbc2 100644 --- a/hyperformula/src/interpreter/plugin/3rdparty/jstat/jstat.ts +++ b/hyperformula/src/interpreter/plugin/3rdparty/jstat/jstat.ts @@ -31,7 +31,7 @@ const SMALLEST_NORMAL_DOUBLE = 2.2250738585072014e-308 /** * erf(x) for 0 <= x < 2 from its series exp(-x^2) * 2 / sqrt(pi) * sum(2^n * x^(2n + 1) / (2n + 1)!!). * All terms are positive, so there is no cancellation, and the relative error stays below about 1.1e-15 down to the - * smallest numbers (the earlier 1 - exp(...) form lost every digit below about 1e-16). + * smallest numbers. */ function erfSeries(x: number): number { const xx = x * x From b2088a88376e45552f5b3710b24dca337a63e6da Mon Sep 17 00:00:00 2001 From: marcin-kordas-hoc Date: Tue, 10 Nov 2026 09:35:46 +0000 Subject: [PATCH 11/12] Keep develop's order of the CHANGELOG sections The develop merge moved the Changed section; develop lists it first. The entry of this pull request stays in Fixed. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa93febedf..1a2129a579 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,15 +7,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] +### Changed + +- **Breaking change**: Changed the license from GPLv3 to a proprietary license. HyperFormula is no longer available under GPLv3; see [`LICENSE.txt`](LICENSE.txt) for the new terms. Versions 3.x and earlier remain available under GPLv3. [#1885](https://github.com/handsontable/hyperformula/pull/1885) + ### Added - Added `LINEST` for simple and multiple linear regression, with optional intercept and regression statistics. The `stats` argument must be constant because result dimensions are determined before evaluation. [#1769](https://github.com/handsontable/hyperformula/pull/1769) - Added the `CONCAT` function, which joins text from values, ranges, and arrays, and the `VALUETOTEXT` function, which returns a value as text in a concise or a strict format. [#1816](https://github.com/handsontable/hyperformula/pull/1816) -### Changed - -- **Breaking change**: Changed the license from GPLv3 to a proprietary license. HyperFormula is no longer available under GPLv3; see [`LICENSE.txt`](LICENSE.txt) for the new terms. Versions 3.x and earlier remain available under GPLv3. [#1885](https://github.com/handsontable/hyperformula/pull/1885) - ### Fixed - Fixed the `EDATE` function returning the 28th of February instead of the 29th when the shifted date falls in February of a leap year (e.g. `=EDATE(DATE(2028, 1, 31), 1)` now returns `2028-02-29` instead of `2028-02-28`). [#1781](https://github.com/handsontable/hyperformula/pull/1781) From e6f078b6f6e8e729548a1e316327b8905330f818 Mon Sep 17 00:00:00 2001 From: marcin-kordas-hoc Date: Sun, 29 Nov 2026 15:17:36 +0000 Subject: [PATCH 12/12] Let NaN reach the continued fraction in erfc instead of a separate guard erfc compares x >= 27.3 so that NaN, which fails every comparison, goes to erfcFraction and comes back as NaN, without a check that no formula can reach. Co-Authored-By: Claude Opus 5.5 --- .../src/interpreter/plugin/3rdparty/jstat/jstat.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/hyperformula/src/interpreter/plugin/3rdparty/jstat/jstat.ts b/hyperformula/src/interpreter/plugin/3rdparty/jstat/jstat.ts index f3aee1dbc2..99f783327b 100644 --- a/hyperformula/src/interpreter/plugin/3rdparty/jstat/jstat.ts +++ b/hyperformula/src/interpreter/plugin/3rdparty/jstat/jstat.ts @@ -78,17 +78,15 @@ export function erf(x: number): number { } export function erfc(x: number): number { - if (Number.isNaN(x)) { - return x - } if (x < 0) { return 2 - erfc(-x) } if (x < 1) { return 1 - erfSeries(x) } - // erfc(27.3) is below the smallest double - const result = x < 27.3 ? erfcFraction(x) : 0 + // erfc(27.3) is below the smallest double. NaN fails every comparison, so it is tested with >= to reach + // erfcFraction, which returns NaN; x < 27.3 would turn it into 0. + const result = x >= 27.3 ? 0 : erfcFraction(x) // A result below the smallest normal double (from about x = 26.55) is returned as 0 return result < SMALLEST_NORMAL_DOUBLE ? 0 : result }