sc/source/core/tool/interpr2.cxx | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
New commits: commit 24d79a75d4e9e419e0d66d22ddaff6353fd83f80 Author: Karthik Godha <[email protected]> AuthorDate: Wed Jan 28 15:09:52 2026 +0530 Commit: Michael Stahl <[email protected]> CommitDate: Thu Jan 29 13:47:23 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]> diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx index 19f54be56792..d12cf5053b35 100644 --- a/sc/source/core/tool/interpr2.cxx +++ b/sc/source/core/tool/interpr2.cxx @@ -979,7 +979,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) {
