The function FACT requires an integer value as input. LibreOffice accepts non-integer values and converts such to integer values. But it does not document how it does it. It could be 'truncate' or 'round'. The ODF standard states, "If the function or operator does not specify any particular conversion operation, then the conversion from a non-integer Number into an integer is implementation-defined." And in case of functions, LibreOffice documents the 'implementation-defined' things in the online help. So add something like "If a passed positive number is non-integer, it is truncated."
https://opengrok.libreoffice.org/xref/core/sc/source/core/tool/interpr3.cxx?r=5a75414d&fi=ScFact#ScFact https://opengrok.libreoffice.org/xref/core/sc/source/core/tool/interpr3.cxx?r=5a75414d&fi=Fakultaet#Fakultaet It uses approxFloor: https://opengrok.libreoffice.org/xref/core/include/rtl/math.hxx?r=40336ee0&fi=approxFloor#approxFloor
Indeed. That makes is more complicate to describe. FACT(4 - (1E-15)) is calculated as FACT(4). FACT(4 - (1E-14)) is calculated as FACT(3).
(In reply to Regina Henschel from comment #2) I don't think we should describe approxFloor in detail: I didn't mean that, I only tried to help by pointing, that it was effectively floor. Indeed, FACT(4 - (1E-15)) is calculated as FACT(4). But also FACT(4 - (1E-25)) is calculated as FACT(4), even if for a different reason. The user-visible behavior is that the whole numbers (as they are displayed at least) are rounded toward negative infinity.
for ref https://help.libreoffice.org/latest/en-US/text/scalc/01/04060106.html#bm_id3153886
others Integer functions (like LCM, ...) dont mention conversion either. So, maybe left to a more central place.
(In reply to fpy from comment #5) I am not sure that we round identically everywhere... I'd start case-by-case first. Maybe create a template like "round to negative infinity", and start attaching to all such places. If there appears another rounding mode, we'd introduce another template.
for ref https://wiki.documentfoundation.org/Documentation/Calc_Functions/FACT
Pierre F committed a patch related to this issue. It has been pushed to "master": https://git.libreoffice.org/help/commit/56220af4577d0f685ca40595f7f57254f92628c4 adjust FACT. tdf#162044