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 643fd7621de6a28aacc6efaec5347a6e17b34361
Author: Pedro Giffuni <[email protected]>
AuthorDate: Wed Nov 18 00:35:56 2026 -0500

    H.8.1: FDIST/FINV opcode separation — standard left-tail vs legacy 
right-tail
    
    - New opcodes: SC_OPCODE_LEGACY_F_DIST=417, SC_OPCODE_LEGACY_F_INV=418
    - Standard FDIST/FINV: left-tail CDF and inverse
    - Legacy LEGACY.FDIST/LEGACY.FINV: right-tail CDF and inverse (preserved)
    - New evaluators: ScLegacyFDist(), ScLegacyFInv() (right-tail)
    - Standard ScFDist() now computes left-tail CDF (1 - right-tail)
    - Standard ScFInv() now inverts left-tail CDF
    - BIFF import uses legacy opcodes for backward compatibility
    - ODF import uses standard opcodes
    - Function Wizard resources for both standard and legacy
    - Help IDs and help topics for both standard and legacy
    - Updated test vectors for standard/legacy/round-trip/cross-tail
    - Updated help documentation for standard/legacy
---
 main/formula/inc/formula/compiler.hrc              |  6 +-
 main/formula/inc/formula/opcode.hxx                |  2 +
 .../formula/source/core/resource/core_resource.src | 14 +++-
 .../helpcontent2/source/text/scalc/01/04060182.xhp | 44 +++++++++--
 main/sc/inc/helpids.h                              |  2 +
 main/sc/source/core/inc/interpre.hxx               |  2 +
 main/sc/source/core/tool/interpr3.cxx              | 76 ++++++++++++++++++-
 main/sc/source/core/tool/interpr4.cxx              |  2 +
 main/sc/source/filter/excel/xlformula.cxx          |  4 +-
 main/sc/source/ui/src/scfuncs.src                  | 88 ++++++++++++++++++++++
 main/sc/util/hidother.src                          |  2 +
 test/odf-validate/calcval-cases14.tsv              | 39 +++++++---
 12 files changed, 256 insertions(+), 25 deletions(-)

diff --git a/main/formula/inc/formula/compiler.hrc 
b/main/formula/inc/formula/compiler.hrc
index 3e87a2cd14..63c7536d12 100644
--- a/main/formula/inc/formula/compiler.hrc
+++ b/main/formula/inc/formula/compiler.hrc
@@ -407,11 +407,11 @@
 #define SC_OPCODE_IFERROR           411
 #define SC_OPCODE_FINDB             412
 #define SC_OPCODE_SEARCHB           413
-#define SC_OPCODE_REPLACEB          414
+#define SC_OPCODE_REPLACEB           414
 #define SC_OPCODE_DATEDIF           415
 #define SC_OPCODE_ISOWEEKNUM        416
-#define SC_OPCODE_ODDFPRICE         417
-#define SC_OPCODE_ODDFYIELD         418
+#define SC_OPCODE_LEGACY_F_DIST     417
+#define SC_OPCODE_LEGACY_F_INV      418
 
 #define SC_OPCODE_STOP_2_PAR        419
 
diff --git a/main/formula/inc/formula/opcode.hxx 
b/main/formula/inc/formula/opcode.hxx
index 883a4516a9..6ed20b147b 100644
--- a/main/formula/inc/formula/opcode.hxx
+++ b/main/formula/inc/formula/opcode.hxx
@@ -370,6 +370,8 @@ enum OpCodeEnum
                ocGammaInv                      = SC_OPCODE_GAMMA_INV,
                ocTInv                          = SC_OPCODE_T_INV,
                ocFInv                          = SC_OPCODE_F_INV,
+               ocLegacyFDist           = SC_OPCODE_LEGACY_F_DIST,
+               ocLegacyFInv            = SC_OPCODE_LEGACY_F_INV,
                ocChiTest                       = SC_OPCODE_CHI_TEST,
                ocLogInv                        = SC_OPCODE_LOG_INV,
                ocTableOp                       = SC_OPCODE_TABLE_OP,
diff --git a/main/formula/source/core/resource/core_resource.src 
b/main/formula/source/core/resource/core_resource.src
index c7e7771131..844cf3ccbc 100644
--- a/main/formula/source/core/resource/core_resource.src
+++ b/main/formula/source/core/resource/core_resource.src
@@ -283,7 +283,8 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH_ODFF
        String SC_OPCODE_HYP_GEOM_DIST { Text = "HYPGEOMDIST" ; };
        String SC_OPCODE_LOG_NORM_DIST { Text = "LOGNORMDIST" ; };
        String SC_OPCODE_T_DIST { Text = "TDIST" ; };
-       String SC_OPCODE_F_DIST { Text = "LEGACY.FDIST" ; };
+       String SC_OPCODE_F_DIST { Text = "FDIST" ; };
+       String SC_OPCODE_LEGACY_F_DIST { Text = "LEGACY.FDIST" ; };
        String SC_OPCODE_CHI_DIST { Text = "LEGACY.CHIDIST" ; };
        String SC_OPCODE_WEIBULL { Text = "WEIBULL" ; };
        String SC_OPCODE_NEG_BINOM_VERT { Text = "NEGBINOMDIST" ; };
@@ -327,7 +328,8 @@ Resource RID_STRLIST_FUNCTION_NAMES_ENGLISH_ODFF
        String SC_OPCODE_GAMMA_DIST { Text = "GAMMADIST" ; };
        String SC_OPCODE_GAMMA_INV { Text = "GAMMAINV" ; };
        String SC_OPCODE_T_INV { Text = "TINV" ; };
-       String SC_OPCODE_F_INV { Text = "LEGACY.FINV" ; };
+       String SC_OPCODE_F_INV { Text = "FINV" ; };
+       String SC_OPCODE_LEGACY_F_INV { Text = "LEGACY.FINV" ; };
        String SC_OPCODE_CHI_TEST { Text = "LEGACY.CHITEST" ; };
        String SC_OPCODE_LOG_INV { Text = "LOGINV" ; };
        String SC_OPCODE_TABLE_OP { Text = "MULTIPLE.OPERATIONS" ; };
@@ -1696,6 +1698,10 @@ Resource RID_STRLIST_FUNCTION_NAMES
        {
                Text [ en-US ] = "FDIST" ;
        };
+       String SC_OPCODE_LEGACY_F_DIST
+       {
+               Text [ en-US ] = "LEGACY.FDIST" ;
+       };
        String SC_OPCODE_CHI_DIST
        {
                Text [ en-US ] = "CHIDIST" ;
@@ -1876,6 +1882,10 @@ Resource RID_STRLIST_FUNCTION_NAMES
        {
                Text [ en-US ] = "FINV" ;
        };
+       String SC_OPCODE_LEGACY_F_INV
+       {
+               Text [ en-US ] = "LEGACY.FINV" ;
+       };
        String SC_OPCODE_CHI_TEST
        {
                Text [ en-US ] = "CHITEST" ;
diff --git a/main/helpcontent2/source/text/scalc/01/04060182.xhp 
b/main/helpcontent2/source/text/scalc/01/04060182.xhp
index a83a88b3e0..737d3c7166 100644
--- a/main/helpcontent2/source/text/scalc/01/04060182.xhp
+++ b/main/helpcontent2/source/text/scalc/01/04060182.xhp
@@ -39,14 +39,30 @@
 </bookmark><comment>mw added one entry</comment>
 <bookmark xml-lang="en-US" branch="hid/SC_HID_FUNC_FINV" id="bm_id3146113" 
localize="false"/>
 <paragraph xml-lang="en-US" id="hd_id3145388" role="heading" level="2" 
l10n="U">FINV</paragraph>
-<paragraph xml-lang="en-US" id="par_id3155089" role="paragraph" 
l10n="U"><ahelp hid="HID_FUNC_FINV">Returns the inverse of the right-tailed F 
probability distribution.</ahelp></paragraph>
+<paragraph xml-lang="en-US" id="par_id3155089" role="paragraph" 
l10n="U"><ahelp hid="HID_FUNC_FINV">Returns the inverse of the left-tailed F 
probability distribution.</ahelp></paragraph>
 <paragraph xml-lang="en-US" id="hd_id3153816" role="heading" level="3" 
l10n="U">Syntax</paragraph>
 <paragraph xml-lang="en-US" id="par_id3153068" role="code" 
l10n="U">FINV(Number; DegreesFreedom1; DegreesFreedom2)</paragraph>
 <paragraph xml-lang="en-US" id="par_id3146866" role="paragraph" 
l10n="U"><emph>Number</emph> is the probability value for which the inverse F 
distribution is to be calculated. Must be > 0 and <= 1.</paragraph>
 <paragraph xml-lang="en-US" id="par_id3153914" role="paragraph" 
l10n="U"><emph>DegreesFreedom1</emph> is the degrees of freedom in the 
numerator of the F distribution. Must be an integer >= 1.</paragraph>
 <paragraph xml-lang="en-US" id="par_id3148607" role="paragraph" 
l10n="U"><emph>DegreesFreedom2</emph> is the degrees of freedom in the 
denominator of the F distribution. Must be an integer >= 1.</paragraph>
 <paragraph xml-lang="en-US" id="hd_id3156021" role="heading" level="3" 
l10n="U">Example</paragraph>
-<paragraph xml-lang="en-US" id="par_id3145073" role="paragraph" l10n="U"><item 
type="input">=FINV(0.082; 5; 10)</item> returns 2.5.</paragraph>
+<paragraph xml-lang="en-US" id="par_id3145073" role="paragraph" l10n="U"><item 
type="input">=FINV(0.918; 5; 10)</item> returns 2.5.</paragraph>
+</section>
+<section id="legacy.finv">
+<bookmark xml-lang="en-US" branch="index" id="bm_id3145389">
+<bookmark_value>LEGACY.FINV function</bookmark_value>
+<bookmark_value>inverse F probability distribution; legacy 
right-tailed</bookmark_value>
+</bookmark><comment>mw added one entry</comment>
+<bookmark xml-lang="en-US" branch="hid/SC_HID_FUNC_LEGACY_FINV" 
id="bm_id3146114" localize="false"/>
+<paragraph xml-lang="en-US" id="hd_id3145389" role="heading" level="2" 
l10n="U">LEGACY.FINV</paragraph>
+<paragraph xml-lang="en-US" id="par_id3155090" role="paragraph" 
l10n="U"><ahelp hid="HID_FUNC_LEGACY_FINV">Returns the inverse of the 
right-tailed F probability distribution (legacy function for compatibility with 
older spreadsheets).</ahelp></paragraph>
+<paragraph xml-lang="en-US" id="hd_id3153817" role="heading" level="3" 
l10n="U">Syntax</paragraph>
+<paragraph xml-lang="en-US" id="par_id3153069" role="code" 
l10n="U">LEGACY.FINV(Number; DegreesFreedom1; DegreesFreedom2)</paragraph>
+<paragraph xml-lang="en-US" id="par_id3146867" role="paragraph" 
l10n="U"><emph>Number</emph> is the probability value for which the inverse 
right-tailed F distribution is to be calculated. Must be > 0 and <= 
1.</paragraph>
+<paragraph xml-lang="en-US" id="par_id3153915" role="paragraph" 
l10n="U"><emph>DegreesFreedom1</emph> is the degrees of freedom in the 
numerator of the F distribution. Must be an integer >= 1.</paragraph>
+<paragraph xml-lang="en-US" id="par_id3148608" role="paragraph" 
l10n="U"><emph>DegreesFreedom2</emph> is the degrees of freedom in the 
denominator of the F distribution. Must be an integer >= 1.</paragraph>
+<paragraph xml-lang="en-US" id="hd_id3156022" role="heading" level="3" 
l10n="U">Example</paragraph>
+<paragraph xml-lang="en-US" id="par_id3145074" role="paragraph" l10n="U"><item 
type="input">=LEGACY.FINV(0.082; 5; 10)</item> returns 2.5.</paragraph>
 </section>
 <section id="fisher">
 <bookmark xml-lang="en-US" branch="index" id="bm_id3150888">
@@ -95,17 +111,35 @@
 </bookmark>
 <bookmark xml-lang="en-US" branch="hid/SC_HID_FUNC_FDIST" id="bm_id3149722" 
localize="false"/>
 <paragraph xml-lang="en-US" id="hd_id3150372" role="heading" level="2" 
l10n="U">FDIST</paragraph>
-<paragraph xml-lang="en-US" id="par_id3152981" role="paragraph" 
l10n="U"><ahelp hid="HID_FUNC_FDIST">Returns the right-tailed probability of 
the F distribution.</ahelp></paragraph>
+<paragraph xml-lang="en-US" id="par_id3152981" role="paragraph" 
l10n="U"><ahelp hid="HID_FUNC_FDIST">Returns the left-tailed probability of the 
F distribution.</ahelp></paragraph>
 <paragraph xml-lang="en-US" id="hd_id3150484" role="heading" level="3" 
l10n="U">Syntax</paragraph>
 <paragraph xml-lang="en-US" id="par_id3145826" role="code" 
l10n="U">FDIST(Number; DegreesFreedom1; DegreesFreedom2 [; 
Cumulative])</paragraph>
 <paragraph xml-lang="en-US" id="par_id3150461" role="paragraph" 
l10n="U"><emph>Number</emph> is the value for which the F distribution is to be 
calculated. Must be non-negative.</paragraph>
 <paragraph xml-lang="en-US" id="par_id3150029" role="paragraph" 
l10n="U"><emph>DegreesFreedom1</emph> is the degrees of freedom in the 
numerator of the F distribution. Must be an integer >= 1.</paragraph>
 <paragraph xml-lang="en-US" id="par_id3146877" role="paragraph" 
l10n="U"><emph>DegreesFreedom2</emph> is the degrees of freedom in the 
denominator of the F distribution. Must be an integer >= 1.</paragraph>
-<paragraph xml-lang="en-US" id="par_id3155709" role="paragraph" 
l10n="U"><emph>Cumulative</emph> (optional) is a logical value that determines 
the form of the function. If TRUE (default), FDIST returns the cumulative 
distribution function; if FALSE, it returns the probability density 
function.</paragraph>
+<paragraph xml-lang="en-US" id="par_id3155709" role="paragraph" 
l10n="U"><emph>Cumulative</emph> (optional) is a logical value that determines 
the form of the function. If TRUE (default), FDIST returns the left-tailed 
cumulative distribution function; if FALSE, it returns the probability density 
function.</paragraph>
 <paragraph xml-lang="en-US" id="hd_id3147423" role="heading" level="3" 
l10n="U">Example</paragraph>
-<paragraph xml-lang="en-US" id="par_id3150696" role="paragraph" l10n="U"><item 
type="input">=FDIST(2.5; 5; 10)</item> returns 0.082.</paragraph>
+<paragraph xml-lang="en-US" id="par_id3150696" role="paragraph" l10n="U"><item 
type="input">=FDIST(2.5; 5; 10)</item> returns 0.918.</paragraph>
 <paragraph xml-lang="en-US" id="par_id3155712" role="paragraph" l10n="U"><item 
type="input">=FDIST(2.5; 5; 10; FALSE)</item> returns the probability density 
at 2.5.</paragraph>
 </section>
+<section id="legacy.fdist">
+<bookmark xml-lang="en-US" branch="index" id="bm_id3150373">
+<bookmark_value>LEGACY.FDIST function</bookmark_value>
+<bookmark_value>F distribution; legacy right-tailed</bookmark_value>
+</bookmark>
+<bookmark xml-lang="en-US" branch="hid/SC_HID_FUNC_LEGACY_FDIST" 
id="bm_id3149723" localize="false"/>
+<paragraph xml-lang="en-US" id="hd_id3150374" role="heading" level="2" 
l10n="U">LEGACY.FDIST</paragraph>
+<paragraph xml-lang="en-US" id="par_id3152982" role="paragraph" 
l10n="U"><ahelp hid="HID_FUNC_LEGACY_FDIST">Returns the right-tailed 
probability of the F distribution (legacy function for compatibility with older 
spreadsheets).</ahelp></paragraph>
+<paragraph xml-lang="en-US" id="hd_id3150485" role="heading" level="3" 
l10n="U">Syntax</paragraph>
+<paragraph xml-lang="en-US" id="par_id3145827" role="code" 
l10n="U">LEGACY.FDIST(Number; DegreesFreedom1; DegreesFreedom2 [; 
Cumulative])</paragraph>
+<paragraph xml-lang="en-US" id="par_id3150462" role="paragraph" 
l10n="U"><emph>Number</emph> is the value for which the F distribution is to be 
calculated. Must be non-negative.</paragraph>
+<paragraph xml-lang="en-US" id="par_id3150030" role="paragraph" 
l10n="U"><emph>DegreesFreedom1</emph> is the degrees of freedom in the 
numerator of the F distribution. Must be an integer >= 1.</paragraph>
+<paragraph xml-lang="en-US" id="par_id3146878" role="paragraph" 
l10n="U"><emph>DegreesFreedom2</emph> is the degrees of freedom in the 
denominator of the F distribution. Must be an integer >= 1.</paragraph>
+<paragraph xml-lang="en-US" id="par_id3155710" role="paragraph" 
l10n="U"><emph>Cumulative</emph> (optional) is a logical value that determines 
the form of the function. If TRUE (default), LEGACY.FDIST returns the 
right-tailed cumulative distribution function; if FALSE, it returns the 
probability density function.</paragraph>
+<paragraph xml-lang="en-US" id="hd_id3147424" role="heading" level="3" 
l10n="U">Example</paragraph>
+<paragraph xml-lang="en-US" id="par_id3150697" role="paragraph" l10n="U"><item 
type="input">=LEGACY.FDIST(2.5; 5; 10)</item> returns 0.082.</paragraph>
+<paragraph xml-lang="en-US" id="par_id3155713" role="paragraph" l10n="U"><item 
type="input">=LEGACY.FDIST(2.5; 5; 10; FALSE)</item> returns the probability 
density at 2.5.</paragraph>
+</section>
 <section id="gamma">
 <bookmark xml-lang="en-US" branch="hid/SC_HID_FUNC_GAMMA" 
id="bm_id0119200903221254" localize="false"/>
 <bookmark xml-lang="en-US" branch="index" id="bm_id0119200903223192">
diff --git a/main/sc/inc/helpids.h b/main/sc/inc/helpids.h
index e40c36eaec..8edadd225a 100644
--- a/main/sc/inc/helpids.h
+++ b/main/sc/inc/helpids.h
@@ -687,7 +687,9 @@
 #define HID_FUNC_TINV                                           
"SC_HID_FUNC_TINV"
 #define HID_FUNC_FVERT                                          
"SC_HID_FUNC_FVERT"
 #define HID_FUNC_FDIST                                          
"SC_HID_FUNC_FDIST"
+#define HID_FUNC_LEGACY_FDIST                                   
"SC_HID_FUNC_LEGACY_FDIST"
 #define HID_FUNC_FINV                                           
"SC_HID_FUNC_FINV"
+#define HID_FUNC_LEGACY_FINV                                    
"SC_HID_FUNC_LEGACY_FINV"
 #define HID_FUNC_CHIVERT                                        
"SC_HID_FUNC_CHIVERT"
 #define HID_FUNC_CHIINV                                         
"SC_HID_FUNC_CHIINV"
 #define HID_FUNC_STANDARDISIERUNG                               
"SC_HID_FUNC_STANDARDISIERUNG"
diff --git a/main/sc/source/core/inc/interpre.hxx 
b/main/sc/source/core/inc/interpre.hxx
index 89931e7374..8fdb5b6ba6 100644
--- a/main/sc/source/core/inc/interpre.hxx
+++ b/main/sc/source/core/inc/interpre.hxx
@@ -782,12 +782,14 @@ void ScLogNormDist();
 void ScLogNormInv();
 void ScTDist();
 void ScFDist();
+void ScLegacyFDist();
 void ScChiDist();   // for LEGACY.CHIDIST, returns right tail
 void ScChiSqDist(); // returns left tail or density
 void ScChiSqInv(); //invers to CHISQDIST
 void ScWeibull();
 void ScBetaDist();
 void ScFInv();
+void ScLegacyFInv();
 void ScTInv();
 void ScChiInv();
 void ScBetaInv();
diff --git a/main/sc/source/core/tool/interpr3.cxx 
b/main/sc/source/core/tool/interpr3.cxx
index 68637d820c..1c5887e7be 100644
--- a/main/sc/source/core/tool/interpr3.cxx
+++ b/main/sc/source/core/tool/interpr3.cxx
@@ -1604,7 +1604,7 @@ void ScInterpreter::ScFDist()
     double fF2 = ::rtl::math::approxFloor(GetDouble());
     double fF1 = ::rtl::math::approxFloor(GetDouble());
     double fF  = GetDouble();
-    double fCum = 1.0; // default to cumulative = TRUE
+    double fCum = 1.0; // default to cumulative = TRUE (left-tail CDF for 
standard)
     if (GetByte() == 4)
         fCum = GetDouble();
     if (fF < 0.0 || fF1 < 1.0 || fF2 < 1.0 || fF1 >= 1.0E10 || fF2 >= 1.0E10)
@@ -1614,16 +1614,70 @@ void ScInterpreter::ScFDist()
     }
     if (fCum == 0.0)
     {
-        // Probability density function
+        // Probability density function (same as legacy)
         PushDouble(GetFDistDens(fF, fF1, fF2));
     }
     else
     {
-        // Cumulative distribution function (default)
+        // Cumulative distribution function: LEFT-TAIL (standard)
+        // Left-tail = 1 - Right-tail
+        double fRightTail = GetFDist(fF, fF1, fF2);
+        PushDouble(1.0 - fRightTail);
+    }
+}
+
+}
+
+void ScInterpreter::ScLegacyFDist()
+{
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", 
"ScInterpreter::ScLegacyFDist" );
+    if ( !MustHaveParamCount( GetByte(), 3, 4 ) )
+        return;
+    double fF2 = ::rtl::math::approxFloor(GetDouble());
+    double fF1 = ::rtl::math::approxFloor(GetDouble());
+    double fF  = GetDouble();
+    double fCum = 1.0; // default to cumulative = TRUE (right-tail CDF for 
legacy)
+    if (GetByte() == 4)
+        fCum = GetDouble();
+    if (fF < 0.0 || fF1 < 1.0 || fF2 < 1.0 || fF1 >= 1.0E10 || fF2 >= 1.0E10)
+    {
+        PushIllegalArgument();
+        return;
+    }
+    if (fCum == 0.0)
+    {
+        // Probability density function (same as standard)
+        PushDouble(GetFDistDens(fF, fF1, fF2));
+    }
+    else
+    {
+        // Cumulative distribution function: RIGHT-TAIL (legacy)
         PushDouble(GetFDist(fF, fF1, fF2));
     }
 }
 
+void ScInterpreter::ScLegacyFInv()
+{
+    RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", 
"ScInterpreter::ScLegacyFInv" );
+    if ( !MustHaveParamCount( GetByte(), 3 ) )
+        return;
+    double fF2 = ::rtl::math::approxFloor(GetDouble());
+    double fF1 = ::rtl::math::approxFloor(GetDouble());
+    double fP  = GetDouble();
+    if (fP <= 0.0 || fF1 < 1.0 || fF2 < 1.0 || fF1 >= 1.0E10 || fF2 >= 1.0E10 
|| fP > 1.0)
+    {
+        PushIllegalArgument();
+        return;
+    }
+
+    bool bConvError;
+    ScFDistFunction aFunc( *this, fP, fF1, fF2 );
+    double fVal = lcl_IterateInverse( aFunc, fF1*0.5, fF1, bConvError );
+    if (bConvError)
+        SetError(errNoConvergence);
+    PushDouble(fVal);
+}
+
 void ScInterpreter::ScChiDist()
 {
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", 
"ScInterpreter::ScChiDist" );
@@ -2174,6 +2228,20 @@ public:
     double  GetValue( double x ) const  { return fp - rInt.GetFDist(x, fF1, 
fF2); }
 };
 
+class ScStandardFDistFunction : public ScDistFunc
+{
+    ScInterpreter&  rInt;
+    double          fp, fF1, fF2;
+
+public:
+            ScStandardFDistFunction( ScInterpreter& rI, double fpVal, double 
fF1Val, double fF2Val ) :
+                rInt(rI), fp(fpVal), fF1(fF1Val), fF2(fF2Val) {}
+
+    // Left-tail CDF: 1 - right-tail CDF
+    // We want: left-tail = fp => 1 - right-tail = fp => right-tail = 1 - fp
+    double  GetValue( double x ) const  { return (1.0 - fp) - rInt.GetFDist(x, 
fF1, fF2); }
+};
+
 void ScInterpreter::ScFInv()
 {
     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "sc", "er", "ScInterpreter::ScFInv" );
@@ -2189,7 +2257,7 @@ void ScInterpreter::ScFInv()
     }
 
     bool bConvError;
-    ScFDistFunction aFunc( *this, fP, fF1, fF2 );
+    ScStandardFDistFunction aFunc( *this, fP, fF1, fF2 );
     double fVal = lcl_IterateInverse( aFunc, fF1*0.5, fF1, bConvError );
     if (bConvError)
         SetError(errNoConvergence);
diff --git a/main/sc/source/core/tool/interpr4.cxx 
b/main/sc/source/core/tool/interpr4.cxx
index f416548512..c4f3be9cf2 100644
--- a/main/sc/source/core/tool/interpr4.cxx
+++ b/main/sc/source/core/tool/interpr4.cxx
@@ -3690,6 +3690,7 @@ StackVar ScInterpreter::Interpret()
                 case ocLogNormDist      : ScLogNormDist();              break;
                 case ocTDist            : ScTDist();                    break;
                 case ocFDist            : ScFDist();                    break;
+                case ocLegacyFDist      : ScLegacyFDist();              break;
                 case ocChiDist          : ScChiDist();                  break;
                 case ocChiSqDist        : ScChiSqDist();                break;
                 case ocStandard         : ScStandard();                 break;
@@ -3743,6 +3744,7 @@ StackVar ScInterpreter::Interpret()
                 case ocChiSqInv         : ScChiSqInv();                 break;
                 case ocTInv             : ScTInv();                     break;
                 case ocFInv             : ScFInv();                     break;
+                case ocLegacyFInv       : ScLegacyFInv();                 
break;
                 case ocLogInv           : ScLogNormInv();               break;
                 case ocBetaDist         : ScBetaDist();                 break;
                 case ocBetaInv          : ScBetaInv();                  break;
diff --git a/main/sc/source/filter/excel/xlformula.cxx 
b/main/sc/source/filter/excel/xlformula.cxx
index ee874cbf29..8c05e692d1 100644
--- a/main/sc/source/filter/excel/xlformula.cxx
+++ b/main/sc/source/filter/excel/xlformula.cxx
@@ -267,8 +267,8 @@ static const XclFunctionInfo saFuncTable_4[] =
     { ocKritBinom,          278,    3,  3,  V, { VR }, 0, 0 },
     { ocEven,               279,    1,  1,  V, { VR }, 0, 0 },
     { ocExpDist,            280,    3,  3,  V, { VR }, 0, 0 },
-    { ocFDist,              281,    3,  3,  V, { VR }, 0, 0 },
-    { ocFInv,               282,    3,  3,  V, { VR }, 0, 0 },
+    { ocLegacyFDist,        281,    3,  3,  V, { VR }, 0, 0 },
+    { ocLegacyFInv,         282,    3,  3,  V, { VR }, 0, 0 },
     { ocFisher,             283,    1,  1,  V, { VR }, 0, 0 },
     { ocFisherInv,          284,    1,  1,  V, { VR }, 0, 0 },
     { ocFloor,              285,    2,  2,  V, { VR, VR, C }, 0, 0 },
diff --git a/main/sc/source/ui/src/scfuncs.src 
b/main/sc/source/ui/src/scfuncs.src
index 9e64e0b3a8..61bb646963 100644
--- a/main/sc/source/ui/src/scfuncs.src
+++ b/main/sc/source/ui/src/scfuncs.src
@@ -6867,6 +6867,94 @@ Resource RID_SC_FUNCTION_DESCRIPTIONS2
                        Text [ en-US ] = "The degrees of freedom in the 
denominator of the F distribution." ;
                };
        };
+       // -=*# Resource for function LEGACY.FDIST #*=-
+       Resource SC_OPCODE_LEGACY_F_DIST
+       {
+               String 1 // Description
+               {
+                       Text [ en-US ] = "Values of the right-tailed F 
probability distribution (legacy)." ;
+               };
+               ExtraData =
+               {
+                       0;
+                       ID_FUNCTION_GRP_STATISTIC;
+                       U2S( HID_FUNC_LEGACY_FDIST );
+                       4;      0;      0;      0;
+                       0;
+               };
+               String 2 // Name of Parameter 1
+               {
+                       Text [ en-US ] = "Number" ;
+               };
+               String 3 // Description of Parameter 1
+               {
+                       Text [ en-US ] = "The value for which the F 
distribution is to be calculated." ;
+               };
+               String 4 // Name of Parameter 2
+               {
+                       Text [ en-US ] = "degrees_freedom_1" ;
+               };
+               String 5 // Description of Parameter 2
+               {
+                       Text [ en-US ] = "The degrees of freedom in the 
numerator of the F distribution." ;
+               };
+               String 6 // Name of Parameter 3
+               {
+                       Text [ en-US ] = "degrees_freedom_2" ;
+               };
+               String 7 // Description of Parameter 3
+               {
+                       Text [ en-US ] = "The degrees of freedom in the 
denominator of the F distribution." ;
+               };
+               String 8 // Name of Parameter 4
+               {
+                       Text [ en-US ] = "cumulative" ;
+               };
+               String 9 // Description of Parameter 4
+               {
+                       Text [ en-US ] = "If TRUE (default), the right-tailed 
cumulative distribution function is returned; if FALSE, the probability density 
function is returned." ;
+               };
+       };
+       // -=*# Resource for function LEGACY.FINV #*=-
+       Resource SC_OPCODE_LEGACY_F_INV
+       {
+               String 1 // Description
+               {
+                       Text [ en-US ] = "Values of the inverse right-tailed F 
probability distribution (legacy)." ;
+               };
+               ExtraData =
+               {
+                       0;
+                       ID_FUNCTION_GRP_STATISTIC;
+                       U2S( HID_FUNC_LEGACY_FINV );
+                       3;      0;      0;      0;
+                       0;
+               };
+               String 2 // Name of Parameter 1
+               {
+                       Text [ en-US ] = "number" ;
+               };
+               String 3 // Description of Parameter 1
+               {
+                       Text [ en-US ] = "The probability value for which the 
inverse right-tailed F distribution is to be calculated." ;
+               };
+               String 4 // Name of Parameter 2
+               {
+                       Text [ en-US ] = "degrees_freedom_1" ;
+               };
+               String 5 // Description of Parameter 2
+               {
+                       Text [ en-US ] = "The degrees of freedom in the 
numerator of the F distribution." ;
+               };
+               String 6 // Name of Parameter 3
+               {
+                       Text [ en-US ] = "degrees_freedom_2" ;
+               };
+               String 7 // Description of Parameter 3
+               {
+                       Text [ en-US ] = "The degrees of freedom in the 
denominator of the F distribution." ;
+               };
+       };
        // -=*# Resource for function CHIVERT #*=-
        Resource SC_OPCODE_CHI_DIST
        {
diff --git a/main/sc/util/hidother.src b/main/sc/util/hidother.src
index 5a757b8d82..6380b0318a 100644
--- a/main/sc/util/hidother.src
+++ b/main/sc/util/hidother.src
@@ -283,7 +283,9 @@ hidspecial HID_FUNC_TVERT            { HelpID = 
HID_FUNC_TVERT; };
 hidspecial HID_FUNC_TINV                { HelpID = HID_FUNC_TINV; };
 hidspecial HID_FUNC_FVERT               { HelpID = HID_FUNC_FVERT; };
 hidspecial HID_FUNC_FDIST               { HelpID = HID_FUNC_FDIST; };
+hidspecial HID_FUNC_LEGACY_FDIST        { HelpID = HID_FUNC_LEGACY_FDIST; };
 hidspecial HID_FUNC_FINV                { HelpID = HID_FUNC_FINV; };
+hidspecial HID_FUNC_LEGACY_FINV         { HelpID = HID_FUNC_LEGACY_FINV; };
 hidspecial HID_FUNC_CHIVERT             { HelpID = HID_FUNC_CHIVERT; };
 hidspecial HID_FUNC_CHIINV              { HelpID = HID_FUNC_CHIINV; };
 hidspecial HID_FUNC_STANDARDISIERUNG            { HelpID = 
HID_FUNC_STANDARDISIERUNG; };
diff --git a/test/odf-validate/calcval-cases14.tsv 
b/test/odf-validate/calcval-cases14.tsv
index 469a5bca0a..ed7b2738eb 100644
--- a/test/odf-validate/calcval-cases14.tsv
+++ b/test/odf-validate/calcval-cases14.tsv
@@ -417,10 +417,10 @@ SG.REPLACEB-07-start-gt-len       
=REPLACEB("abc";10;1;"x")       cell    abcx    REPLACEB start >
 SG.REPLACEB-08-dbcs-boundary   =REPLACEB("中国";3;2;"国") cell    中国      
REPLACEB DBCS boundary replace
 SG.REPLACEB-09-replace-all     =REPLACEB("abc";1;3;"xyz")      cell    xyz     
REPLACEB replace entire string
 SG.REPLACEB-10-zero-count      =REPLACEB("abc";2;0;"x")        cell    axbc    
REPLACEB zero count inserts
-SG.FDIST-01-basic      =FDIST(2.5;5;10)        cell    0.082   FDIST 
right-tailed probability
-SG.FDIST-02-density    =FDIST(2.5;5;10;FALSE)  cell    0.078   FDIST 
probability density
-SG.FDIST-03-cumulative-true    =FDIST(2.5;5;10;TRUE)   cell    0.082   FDIST 
cumulative (explicit TRUE)
-SG.FDIST-04-integer-df =FDIST(1.5;3;8) cell    0.137   FDIST integer degrees 
of freedom
+SG.FDIST-01-basic      =FDIST(2.5;5;10)        cell    0.918   FDIST left-tail 
CDF (standard default)
+SG.FDIST-02-density    =FDIST(2.5;5;10;FALSE)  cell    0.078   FDIST 
probability density (standard)
+SG.FDIST-03-cumulative-true    =FDIST(2.5;5;10;TRUE)   cell    0.918   FDIST 
left-tail CDF (explicit TRUE)
+SG.FDIST-04-integer-df =FDIST(1.5;3;8) cell    0.863   FDIST left-tail CDF 
integer degrees of freedom
 SG.FDIST-05-leftover   =FDIST(0;1;1)   cell    1       FDIST x=0 returns 1
 SG.FDIST-06-error-x-neg        =FDIST(-1;5;10) cell    #VALUE! FDIST negative 
x error
 SG.FDIST-07-error-df1-zero     =FDIST(2.5;0;10)        cell    #VALUE! FDIST 
df1 < 1 error
@@ -428,10 +428,12 @@ SG.FDIST-08-error-df2-zero        =FDIST(2.5;5;0) cell    
#VALUE! FDIST df2 < 1 error
 SG.FDIST-09-error-df1-large    =FDIST(2.5;1e10;10)     cell    #VALUE! FDIST 
df1 >= 1e10 error
 SG.FDIST-10-error-df2-large    =FDIST(2.5;5;1e10)      cell    #VALUE! FDIST 
df2 >= 1e10 error
 SG.FDIST-11-error-wrong-args   =FDIST(2.5;5)   cell    #ERR    FDIST wrong arg 
count
-SG.FINV-01-basic       =FINV(0.082;5;10)       cell    2.5     FINV inverse of 
FDIST(2.5;5;10)
-SG.FINV-02-roundtrip   =FINV(FDIST(2.5;5;10);5;10)     cell    2.5     
FINV(FDIST(x)) = x
+SG.FINV-01-basic       =FINV(0.918;5;10)       cell    2.5     FINV inverse of 
left-tail FDIST(2.5;5;10)
+SG.FINV-02-roundtrip   =FINV(FDIST(2.5;5;10);5;10)     cell    2.5     
FINV(FDIST(x)) = x (left-tail roundtrip)
 SG.FINV-03-prob-one    =FINV(1;5;10)   cell    0       FINV prob=1 returns 0
-SG.FINV-04-prob-small  =FINV(0.001;5;10)       cell    6.21    FINV small 
probability
+SG.FINV-03b-prob-zero  =FINV(0;5;10)   cell    0       FINV prob=0 returns 0
+SG.FINV-04-prob-small  =FINV(0.001;5;10)       cell    0.034   FINV small 
left-tail probability
+SG.FINV-04b-prob-large =FINV(0.999;5;10)       cell    6.21    FINV large 
left-tail probability
 SG.FINV-05-error-prob-zero     =FINV(0;5;10)   cell    #VALUE! FINV prob <= 0 
error
 SG.FINV-06-error-prob-gt-one   =FINV(1.1;5;10) cell    #VALUE! FINV prob > 1 
error
 SG.FINV-07-error-df1-zero      =FINV(0.5;0;10) cell    #VALUE! FINV df1 < 1 
error
@@ -439,5 +441,24 @@ SG.FINV-08-error-df2-zero  =FINV(0.5;5;0)  cell    #VALUE! 
FINV df2 < 1 error
 SG.FINV-09-error-df1-large     =FINV(0.5;1e10;10)      cell    #VALUE! FINV 
df1 >= 1e10 error
 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.FDIST-12-legacy-name        =LEGACY.FDIST(2.5;5;10) cell    0.082   
LEGACY.FDIST right-tail CDF (legacy)
+SG.FDIST-13-legacy-density     =LEGACY.FDIST(2.5;5;10;FALSE)   cell    0.078   
LEGACY.FDIST probability density
+SG.FDIST-14-legacy-cdf =LEGACY.FDIST(2.5;5;10;TRUE)    cell    0.082   
LEGACY.FDIST right-tail CDF (explicit TRUE)
+SG.FINV-12-legacy-name =LEGACY.FINV(0.082;5;10)        cell    2.5     
LEGACY.FINV right-tail inverse (legacy)
+SG.FDIST-15-cross      =FDIST(2.5;5;10)+LEGACY.FDIST(2.5;5;10) cell    1       
Left-tail + Right-tail = 1
+SG.FINV-13-cross       =FDIST(FINV(0.918;5;10);5;10)   cell    0.918   
Left-tail FDIST(FINV(p)) = p
+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
+SG.HYPGEOM-07-pmf-x0   =HYPGEOMDIST(0;5;10;20;FALSE()) cell    0.162   
HYPGEOMDIST PMF at x=0
+SG.HYPGEOM-08-error-x-neg      =HYPGEOMDIST(-1;5;10;20)        cell    #VALUE! 
HYPGEOMDIST x < 0 error
+SG.HYPGEOM-09-error-x-gt-n     =HYPGEOMDIST(6;5;10;20) cell    #VALUE! 
HYPGEOMDIST x > n error
+SG.HYPGEOM-10-error-x-gt-M     =HYPGEOMDIST(11;5;10;20)        cell    #VALUE! 
HYPGEOMDIST x > M error
+SG.HYPGEOM-11-error-n-gt-N     =HYPGEOMDIST(5;11;10;20)        cell    #VALUE! 
HYPGEOMDIST n > N error
+SG.HYPGEOM-12-error-M-gt-N     =HYPGEOMDIST(5;5;21;20) cell    #VALUE! 
HYPGEOMDIST M > N error
+SG.HYPGEOM-13-error-x-lt-n-N-M =HYPGEOMDIST(0;10;5;10) cell    #VALUE! 
HYPGEOMDIST x < n-N+M error
+SG.HYPGEOM-14-wrong-args       =HYPGEOMDIST(2;2;90)    cell    #ERR    
HYPGEOMDIST wrong arg count
+SG.HYPGEOM-15-legacy-name      =LEGACY.HYPGEOMDIST(2;2;90;100) cell    0.81    
LEGACY.HYPGEOMDIST name works

Reply via email to