This is an automated email from the ASF dual-hosted git repository. asf-gitbox-commits pushed a commit to branch openformula in repository https://gitbox.apache.org/repos/asf/openoffice.git
commit 38aedfe2f665f216d9947fcf3700c493d5a1d2da Author: Pedro Giffuni <[email protected]> AuthorDate: Wed Nov 18 00:10:00 2026 -0500 H.9.1: Fix HYPGEOMDIST cumulative default for backward compatibility - 4-argument calls return PMF (Cumulative=FALSE) for legacy Excel/Calc compatibility - 5-argument calls respect explicit Cumulative flag (TRUE=CDF, FALSE=PMF) - Updated help text to clarify default behavior for 4-arg vs 5-arg calls - Updated test comments to reflect correct expectations --- main/helpcontent2/source/text/scalc/01/04060182.xhp | 2 +- main/sc/source/core/tool/interpr3.cxx | 5 +++-- test/odf-validate/calcval-cases14.tsv | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/main/helpcontent2/source/text/scalc/01/04060182.xhp b/main/helpcontent2/source/text/scalc/01/04060182.xhp index ad52acd7f6..78e390ca5f 100644 --- a/main/helpcontent2/source/text/scalc/01/04060182.xhp +++ b/main/helpcontent2/source/text/scalc/01/04060182.xhp @@ -284,7 +284,7 @@ <paragraph xml-lang="en-US" id="par_id3153106" role="paragraph" l10n="U"><emph>NSample</emph> is the size of the random sample.</paragraph> <paragraph xml-lang="en-US" id="par_id3146992" role="paragraph" l10n="U"><emph>Successes</emph> is the number of possible results in the total population.</paragraph> <paragraph xml-lang="en-US" id="par_id3148826" role="paragraph" l10n="U"><emph>NPopulation</emph> is the size of the total population.</paragraph> -<paragraph xml-lang="en-US" id="par_id3155389" role="paragraph" l10n="U"><emph>Cumulative</emph> (optional) is a logical value that determines the form of the function. If TRUE (default), HYPGEOMDIST returns the cumulative distribution function; if FALSE, it returns the probability mass function.</paragraph> +<paragraph xml-lang="en-US" id="par_id3155389" role="paragraph" l10n="U"><emph>Cumulative</emph> (optional) is a logical value that determines the form of the function. If TRUE, HYPGEOMDIST returns the cumulative distribution function; if FALSE or omitted, it returns the probability mass function. For four-argument calls, the default is FALSE (probability mass function) for backward compatibility with legacy spreadsheets.</paragraph> <paragraph xml-lang="en-US" id="hd_id3150529" role="heading" level="3" l10n="U">Example</paragraph> <paragraph xml-lang="en-US" id="par_id3154904" role="paragraph" l10n="U"><item type="input">=HYPGEOMDIST(2;2;90;100)</item> yields 0.81. If 90 out of 100 pieces of buttered toast fall from the table and hit the floor with the buttered side first, then if 2 pieces of buttered toast are dropped from the table, the probability is 81%, that both will strike buttered side first.</paragraph> <paragraph xml-lang="en-US" id="par_id3155390" role="paragraph" l10n="U"><item type="input">=HYPGEOMDIST(2;2;90;100;FALSE())</item> yields the probability mass function value at 2.</paragraph> diff --git a/main/sc/source/core/tool/interpr3.cxx b/main/sc/source/core/tool/interpr3.cxx index 659cf0dfdb..7ef4a2b4ee 100644 --- a/main/sc/source/core/tool/interpr3.cxx +++ b/main/sc/source/core/tool/interpr3.cxx @@ -1940,8 +1940,9 @@ static double lcl_CalcHypGeomPMF( double N, double M, double n, double k ) double n = ::rtl::math::approxFloor(GetDouble()); double x = ::rtl::math::approxFloor(GetDouble()); - // Default Cumulative = TRUE (ODF/Excel default) - double bCumulative = 1.0; + // Default Cumulative = FALSE (PMF) for 4-arg legacy compatibility + // 5-arg calls use explicit Cumulative flag + double bCumulative = 0.0; if ( GetByte() == 5 ) bCumulative = GetBool(); diff --git a/test/odf-validate/calcval-cases14.tsv b/test/odf-validate/calcval-cases14.tsv index 131eb509f6..2429a4579e 100644 --- a/test/odf-validate/calcval-cases14.tsv +++ b/test/odf-validate/calcval-cases14.tsv @@ -441,9 +441,9 @@ SG.FINV-10-error-df2-large =FINV(0.5;5;1e10) cell #VALUE! FINV df2 >= 1e10 error SG.FINV-11-error-wrong-args =FINV(0.5;5) cell #ERR FINV wrong arg count SG.FDIST-12-legacy-name =LEGACY.FDIST(2.5;5;10) cell 0.082 LEGACY.FDIST name works SG.FINV-12-legacy-name =LEGACY.FINV(0.082;5;10) cell 2.5 LEGACY.FINV name works -SG.HYPGEOM-01-pmf =HYPGEOMDIST(2;2;90;100;FALSE()) cell 0.81 HYPGEOMDIST PMF (legacy 4-arg compatible) -SG.HYPGEOM-02-cdf =HYPGEOMDIST(2;2;90;100;TRUE()) cell 0.81 HYPGEOMDIST CDF -SG.HYPGEOM-03-legacy =HYPGEOMDIST(2;2;90;100) cell 0.81 HYPGEOMDIST legacy 4-arg (defaults to PMF? No - should be CDF per ODF) +SG.HYPGEOM-01-pmf =HYPGEOMDIST(2;2;90;100;FALSE()) cell 0.81 HYPGEOMDIST PMF (explicit FALSE) +SG.HYPGEOM-02-cdf =HYPGEOMDIST(2;2;90;100;TRUE()) cell 0.81 HYPGEOMDIST CDF (explicit TRUE) +SG.HYPGEOM-03-legacy =HYPGEOMDIST(2;2;90;100) cell 0.81 HYPGEOMDIST legacy 4-arg returns PMF (backward compat) SG.HYPGEOM-04-pmf-small =HYPGEOMDIST(1;4;4;10;FALSE()) cell 0.380952381 HYPGEOMDIST PMF sample SG.HYPGEOM-05-cdf-small =HYPGEOMDIST(1;4;4;10;TRUE()) cell 0.714285714 HYPGEOMDIST CDF sample SG.HYPGEOM-06-cdf-x0 =HYPGEOMDIST(0;5;10;20;TRUE()) cell 0.162 HYPGEOMDIST CDF at x=0
