Difference between revisions of "Documentation/How Tos/Calc: FLOOR function"

From Apache OpenOffice Wiki
Jump to: navigation, search
(Initial content)
 
m
Line 3: Line 3:
 
== FLOOR ==
 
== FLOOR ==
 
Returns a number rounded down to a multiple of another number.
 
Returns a number rounded down to a multiple of another number.
 
  
 
=== Syntax: ===
 
=== Syntax: ===
Line 10: Line 9:
  
 
: If <tt>'''mode'''</tt> is zero or omitted, <tt>'''FLOOR'''</tt> rounds down ''to the multiple below'' (more negative than or equal to) <tt>'''number'''</tt>. If <tt>'''mode'''</tt> is non-zero, <tt>'''FLOOR'''</tt> rounds down towards zero. This difference is only relevant with negative numbers.
 
: If <tt>'''mode'''</tt> is zero or omitted, <tt>'''FLOOR'''</tt> rounds down ''to the multiple below'' (more negative than or equal to) <tt>'''number'''</tt>. If <tt>'''mode'''</tt> is non-zero, <tt>'''FLOOR'''</tt> rounds down towards zero. This difference is only relevant with negative numbers.
 
  
 
: Use <tt>'''mode'''</tt><nowiki>=</nowiki><tt>'''1'''</tt> for compability if you have negative numbers and wish to export to MS Excel. In MS Excel this function only takes two arguments.
 
: Use <tt>'''mode'''</tt><nowiki>=</nowiki><tt>'''1'''</tt> for compability if you have negative numbers and wish to export to MS Excel. In MS Excel this function only takes two arguments.
 
  
 
=== Example: ===
 
=== Example: ===
Line 30: Line 27:
 
<tt>'''FLOOR( -11; -2; 1)'''</tt>
 
<tt>'''FLOOR( -11; -2; 1)'''</tt>
 
: returns <tt>'''-10'''</tt>,  because with mode=<tt>'''1'''</tt> the function rounds towards zero.
 
: returns <tt>'''-10'''</tt>,  because with mode=<tt>'''1'''</tt> the function rounds towards zero.
 
  
 
=== See also: ===
 
=== See also: ===

Revision as of 06:32, 2 March 2008


FLOOR

Returns a number rounded down to a multiple of another number.

Syntax:

FLOOR(number; mult; mode)

number is the number that is to be rounded down to a multiple of mult.
If mode is zero or omitted, FLOOR rounds down to the multiple below (more negative than or equal to) number. If mode is non-zero, FLOOR rounds down towards zero. This difference is only relevant with negative numbers.
Use mode=1 for compability if you have negative numbers and wish to export to MS Excel. In MS Excel this function only takes two arguments.

Example:

FLOOR(8; 3)

returns 6, because 2*3 = 6 is the first multiple of 3 below 8.

FLOOR(6; 3)

returns 6.

FLOOR( -11; -2)

returns -12, rounding to the multiple below.

FLOOR( -11; -2; 0)

returns -12.

FLOOR( -11; -2; 1)

returns -10, because with mode=1 the function rounds towards zero.

See also:

CEILING, EVEN, ODD, MROUND

INT, TRUNC, ROUND, ROUNDDOWN, ROUNDUP

Mathematical functions

Personal tools