MathLib.floor()

MathLib.floor() returns the greatest integer smaller or equal the argument. \[ \text{MathLib.floor}(x) = \lfloor x \rfloor \]

Examples

Evaluating

To calculate the floor of 2.5 type: MathLib.floor(2.5);

Plotting

It is very easy to generate a plot of the floor function: var plot = new MathLib.Screen2D('plot', { width: 300, height: 300, lookAt: {x: 0, y: 1.5}, range: {x: 1.75, y: 1.75} }); MathLib.floor.draw(plot, { lineColor: 'blue' });

Specification

MathLib.floor accepts one argument. Any additional arguments will be ignored. The type of the argument should be number. For other argument types see the unary function specification.
  1. MathLib.floor(NaN) = NaN
  2. MathLib.floor(+0) = +0
  3. MathLib.floor(-0) = -0
  4. MathLib.floor(+∞) = +∞
  5. MathLib.floor(-∞) = -∞
  6. otherwise MathLib.floor(x) = ⎣x⎦

Implementation

MathLib uses the built-in JavaScript function Math.floor.

Tests

Categories: unary Function