floor

Syntax

floor(X)

Details

The floor and ceil functions map a real number to the largest previous and the smallest following integer, respectively. Function round maps a real number to the largest previous or the smallest following integer with the round half up rule.
Note:
  • Difference from Python’s numpy.floor: Both functions return the largest integer less than or equal to the input. numpy.floor is a ufunc and supports broadcasting, out, where, and other ufunc arguments. DolphinDB’s floor accepts a scalar, vector, or matrix and returns an integral result.
  • DolphinDB floor has the same core functionality as TA-Lib FLOOR. The difference is that DolphinDB floor supports scalar, pair, vector, matrix, and table inputs, whereas TA-Lib FLOOR only accepts one-dimensional array (NumPy array) inputs. If the input data is the same, both return identical results.

Parameters

X is a scalar, vector, or matrix.

Returns

An integer scalar, vector or matrix.

Examples

floor(2.1);
// output: 2
floor(2.9);
// output: 2
floor(-2.1);
// output: -3

ceil(2.1);
// output: 3
ceil(2.9);
// output: 3
ceil(-2.1);
// output: -2

round(2.1);
// output: 2
round(2.9);
// output: 3
round(-2.1);
// output: -2
m = 1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 10$2:5;
m;
#0 #1 #2 #3 #4
1.1 3.3 5.5 7.7 9.9
2.2 4.4 6.6 8.8 10
floor(m);
#0 #1 #2 #3 #4
1 3 5 7 9
2 4 6 8 10