Floor

is a monadic scalar function that gives the floor of a real number, that is, the greatest integer tolerantly less than or equal to the given value. This operation is also known as integral part, entier, and round down. Floor shares the glyph  with the dyadic arithmetic function Minimum. Traditional mathematics derives its notation and name for floor from APL.

Examples
Floor rounds down the given numbers to the nearest integers.

Rounding to the nearest integer (rounding up on half) can be achieved by adding 0.5 before applying Floor.

Integral quotient of division can be found with division followed by Floor.

Properties
The floor of any real number is an integer.

Floor is affected by comparison tolerance. If the given number is tolerantly equal to its ceiling, it is rounded to that number instead.

Model
Floor can very easily be modelled using residue like:

To model it without using residue, because residue uses floor under the hood, approaches like converting to strings and then stripping the decimal component or converting to binary and stripping the decimal component can be used.

Converting to the exponent/scientific notation (123E¯2) and then using the exponent and mantissa to strip the decimal points can be used.

Warning: However, the method present here has issues dealing with larger values due to the loss in precision because of the ⍎ operator.

Other approaches could include writing a hungry loop to evaluate the closest integer value and evaluate from there.

Complex floor

 * Main article: Complex Floor

Eugene McDonnell designed the domain extension of Floor to complex numbers. Complex floor maps every complex number to a Gaussian integer, a complex number whose real and imaginary parts are integers. It has an important property that the magnitude of difference between any complex number Z and its floor is less than 1. This extension is currently implemented in Dyalog APL, J, and NARS2000, and is internally used to implement complex ceiling, residue, and GCD.

Documentation

 * Dyalog
 * APLX
 * J Dictionary, NuVoc
 * BQN