floor()
Returns the largest integer that is less than or equal to a given number, Numbers with decimal places are rounded down to the nearest integer by default. This function takes only the numeric data type as an argument. If an integer comes in as an argument, this returns the input as it is. If it receives any other type, it returns null
.
Syntax
floor(NUM_EXPR[, NUM_DIGITS])
Required Parameter
NUM_EXPR
- Expression that returns int, short, long, float, or double.
NUM_DIGITS
- Number of digits to which you want to round down the number. If you specify a negative number as
NUM_DIGITS
, the function rounds down to the left of the decimal point.
Usage
json "{}" | eval floor=floor(1.1) => 1
json "{}" | eval floor=floor(1.61, 1) => 1.6
json "{}" | eval floor=floor(531, -1) => 530
json "{}" | eval floor=floor(5) => 5
json "{}" | eval floor=floor("1.1") => null
json "{}" | eval floor=floor("asdf") => null
json "{}" | eval floor=floor(4.3, "eediom") => null