sc/source/core/tool/interpr2.cxx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
New commits: commit 6ddb73687ff7ed0df287c4281db616baa00df91e Author: Karthik Godha <[email protected]> AuthorDate: Wed Jan 28 15:09:52 2026 +0530 Commit: Karthik Godha <[email protected]> CommitDate: Mon Feb 16 03:18:16 2026 +0100 sc: Accept larger values in TRUNC function If the second argument in TRUNC function is greater than int16 then the function returns an error. Accept larger values for 2nd argument to make it interoperable with Excel. bug-document: forum-mso-de-11803 Change-Id: I9de5c1a2ed71831d4b1c0cf16ea0902c4e1de628 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/198279 Reviewed-by: Michael Stahl <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> (cherry picked from commit 24d79a75d4e9e419e0d66d22ddaff6353fd83f80) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/199429 Tested-by: Jenkins Reviewed-by: Karthik Godha <[email protected]> diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx index d12b5c4dbb54..ddef32baa82e 100644 --- a/sc/source/core/tool/interpr2.cxx +++ b/sc/source/core/tool/interpr2.cxx @@ -970,7 +970,19 @@ void ScInterpreter::RoundNumber( rtl_math_RoundingMode eMode ) fVal = ::rtl::math::round( GetDouble(), 0, eMode ); else { - const sal_Int16 nDec = GetInt16(); + double fDec = GetDouble(); + if (fDec > SAL_MAX_INT16) + fDec = SAL_MAX_INT16; + else if (fDec < SAL_MIN_INT16) + fDec = SAL_MIN_INT16; + else + { + if (fDec < 0.0) + fDec = rtl::math::approxCeil(fDec); + else + fDec = rtl::math::approxFloor(fDec); + } + const sal_Int16 nDec = static_cast<sal_Int16>(fDec); const double fX = GetDouble(); if (nGlobalError == FormulaError::NONE) {
