Function in prelude::math auto-imported

floor

fn floor(float x) -> float
Source: compiler/src/builtin_docs/prelude/math.hy

Returns the largest whole number less than or equal to x, as a float.

Use floor(x) as int to get an int.

Parameters#

NameType
xfloat

Returns#

float

Examples#

use tests::assert;
assert!(floor(2.7) == 2.0);
assert!(floor(-2.1) == -3.0);

See also#

  • float
  • int
  • sin: Returns the sine of x (in radians).
  • cos: Returns the cosine of x (in radians).
  • tan: Returns the tangent of x (in radians).
  • sqrt: Returns the square root of x.
  • ceil: Returns the smallest whole number greater than or equal to x, as a float.
  • exp: Returns e raised to the power x.
↑ ↓ navigate ↵ open