Documentation/Calc Functions/FLOOR

    From The Document Foundation Wiki
    Other languages:


    Function name:

    FLOOR

    Category:

    Mathematical

    Summary:

    Rounds a number to the nearest multiple of a significance value. In most cases, the number is rounded down (toward -∞). However, a mode parameter is provided and when this is set to a non-zero value, then negative numbers are rounded up (toward +∞).

    Syntax:

    FLOOR(Number [; Significance[; Mode]])

    Returns:

    Returns a real number that is the rounded value and is an integer multiple of the significance value.

    Arguments:

    Number is a real number, or a reference to a cell containing that number, that is the value to be rounded.

    Significance is a real number, or a reference to a cell containing that number, that is the significance value to be used. If omitted, Significance defaults to +1 or -1 depending on the sign of Number.

    Mode is a real number, or a reference to a cell containing that number, that is a Boolean mode indicator. Mode is only effective when both Number and Significance are negative. If Mode is present and equal to any non-zero value (including TRUE), negative numbers are rounded up (toward +∞). If Mode is omitted, or equal to zero or FALSE, negative numbers are rounded down (toward -∞).

    • If any argument is non-numeric, then FLOOR reports a #VALUE! error.
    • If one of Number or Significance is positive while the other is negative, then FLOOR reports an invalid argument error (Err:502).
    • If either Number or Significance is equal to 0, then FLOOR returns 0.

    Additional details:

    Details specific to FLOOR function

    • With Significance set or defaulted to -1 or +1 (with the same sign as Number) and Mode set or defaulted to 0 or FALSE, FLOOR provides functionality that implements the standard mathematical definition of a floor value.
    • If you export a spreadsheet to Microsoft Excel, calls to the FLOOR function are converted to FLOOR.MATH (FLOOR.MATH has existed in Excel since Excel 2013). If you intend to use a spreadsheet with earlier Excel versions, use either the FLOOR.PRECISE function (that has existed in Excel since Excel 2010), or the FLOOR.XCL function that is converted to FLOOR on export and should be compatible with all Excel versions.


    General information about Calc's floor functions

    Note pin.svg

    Note:
    For convenience, the information in this subsection is repeated on all pages describing Calc’s floor functions.

    General introductory information about floor functions can be found at Wikipedia's Floor and ceiling functions page.

    Calc provides four functions that can be used to calculate the floor value of a number, and these are:

    The most important of these for many users will be the FLOOR function, which implements the requirements laid out in Section 6.17.3 of ODF 1.2, Part 2.

    Calc provides the FLOOR.MATH, and FLOOR.PRECISE functions to increase interoperability with Microsoft Excel, which provides two similar functions with the same names.

    Microsoft Excel's FLOOR function accepts two arguments and so is not compliant with ODF 1.2. This difference in behaviour could lead to interoperability problems but these are avoided through the provision of the FLOOR.XCL function, as follows:

    • When Calc saves a spreadsheet to Excel 2007-365 (*.xlsx) format, any call to Calc's FLOOR function is converted to a call to Excel's FLOOR.MATH function, and any call to Calc's FLOOR.XCL function is converted to a call to Excel's FLOOR function.
    • When Calc opens a spreadsheet in Excel 2007-365 (*.xlsx) format, any call to Excel's FLOOR function is converted to a call to Calc's FLOOR.XCL function.

    Examples:

    Formula Description Returns
    =FLOOR(11.5) Significance defaults to +1 and Mode defaults to 0. The function rounds down 11.5 to the nearest integer multiple of +1. 11
    =FLOOR(−11.5) Significance defaults to -1 and Mode defaults to 0. The function rounds down -11.5 to the nearest integer multiple of -1. −12
    =FLOOR(7; 2.3) Mode defaults to 0. The function rounds down 7 to the nearest integer multiple of 2.3. 6.9
    =FLOOR(−7; −2.3) Mode defaults to 0. The function rounds down -7 to the nearest integer multiple of -2.3. −9.2
    =FLOOR(D1; D2; D3) where cells D1, D2, and D3 contain the numbers 10, 3, and 1 respectively. The function rounds down the value 10 to the nearest integer multiple of 3. The value of Mode is not significant for a positive number. 9
    =FLOOR(−10; −3; 0) With Mode set to 0, the function rounds down the value -10 to the nearest integer multiple of -3. −12
    =FLOOR(−10; −3; 7.6) With Mode set to a non-zero value, the function rounds up the value of -10 to the nearest integer multiple of -3. −9
    =FLOOR(−3.6; ; TRUE()) Significance defaults to -1. With Mode set to a non-zero value, the function rounds up the value of -3.6 to the nearest integer multiple of -1. −3

    Related LibreOffice functions:

    CEILING

    CEILING.MATH

    CEILING.PRECISE

    CEILING.XCL

    FLOOR.MATH

    FLOOR.PRECISE

    FLOOR.XCL

    INT

    ISO.CEILING

    ODF standard:

    Section 6.17.3, part 2

    Related (or similar) Excel functions:

    FLOOR.MATH