Documentation

floor

Round down to the next integer

Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

Syntax

floor(x)

Description

floor rounds a number to the next smaller integer.

For complex arguments, floor rounds the real and the imaginary parts separately.

For real numbers and exact expressions representing real numbers, floor returns integers.

For arguments that contain symbolic identifiers, floor returns unevaluated function calls.

For floating-point intervals, floor returns floating-point intervals containing all the results of applying floor to the real or complex numbers inside the interval.

    Note:   If the argument is a floating-point number of absolute value larger than 10DIGITS, the resulting integer is affected by internal non-significant digits. See Example 2.

    Note:   Internally, exact numerical expressions that are neither integers nor rational numbers are approximated by floating-point numbers before rounding. Thus, the resulting integer depends on the current DIGITS setting. See Example 3.

Environment Interactions

The functions are sensitive to the environment variable DIGITS which determines the numerical working precision.

Examples

Example 1

Round the following real and complex numbers:

floor(3.5), floor(-7/2), floor(4.3 + 7*I)

Round the following symbolic expression representing a number:

floor(PI*I + 7*sin(exp(2)))

Rounding of expressions with symbolic identifiers produces unevaluated function calls:

floor(x - 1)

Example 2

Rounding floating-point numbers of large absolute value is affected by internal non-significant digits:

x := 10^30/3.0

Note that only the first 10 decimal digits are "significant". Further digits are subject to round-off effects caused by the internal binary representation. These "insignificant" digits are part of the integer produced by rounding:

floor(x)

delete x:

Example 3

Exact numerical expressions are internally converted to floating point numbers before rounding. Consequently, the current setting of DIGITS can affect the result:

x := 10^30 - exp(30)^ln(10)

Note that the exact value of this number is 0. Floating-point evaluation is subject to severe cancellations:

DIGITS := 10:
float(x), floor(x)

The floating-point result is more accurate when calculated with a higher precision. The rounded values change accordingly:

DIGITS := 20:
float(x), floor(x)

DIGITS := 30:
float(x), floor(x)

delete x, DIGITS:

Example 4

On floating-point intervals, floor behaves as follows:

floor(3.5...6.7)

This interval contains the results of floor(x) for all .

Because there are finite numbers represented as RD_INF and RD_NINF, respectively, floor returns very small or large representable numbers in certain cases:

ceil(RD_NINF...RD_NINF)

Return Values

Arithmetical expression.

Overloaded By

x

See Also

MuPAD Functions

Was this topic helpful?