floor - Round toward negative infinity

Syntax

y = floor(a)

Description

y = floor(a) rounds fi object a to the nearest integer in the direction of negative infinity and returns the result in fi object y.

y and a have the same fimath object and DataType property.

When the DataType property of a is single, double, or boolean, the numerictype of y is the same as that of a.

When the fraction length of a is zero or negative, a is already an integer, and the numerictype of y is the same as that of a.

When the fraction length of a is positive, the fraction length of y is 0, its sign is the same as that of a, and its word length is the difference between the word length and the fraction length of a. If a is signed, then the minimum word length of y is 2. If a is unsigned, then the minimum word length of y is 1.

For complex fi objects, the imaginary and real parts are rounded independently.

floor does not support fi objects with nontrivial slope and bias scaling. Slope and bias scaling is trivial when the slope is an integer power of 2 and the bias is 0.

Examples

Example 1

The following example demonstrates how the floor function affects the numerictype properties of a signed fi object with a word length of 8 and a fraction length of 3.

a = fi(pi, 1, 8, 3) 

a =
 
    3.1250

DataTypeMode: Fixed-point: binary point scaling
Signed: true
WordLength: 8
FractionLength: 3

y = floor(a) 

y =
 
     3

DataTypeMode: Fixed-point: binary point scaling
Signed: true
WordLength: 5
FractionLength: 0

Example 2

The following example demonstrates how the floor function affects the numerictype properties of a signed fi object with a word length of 8 and a fraction length of 12.

a = fi(0.025,1,8,12) 

a =
 
    0.0249

          DataTypeMode: Fixed-point: binary point scaling
                Signed: true
            WordLength: 8
        FractionLength: 12

y = floor(a) 

y =
 
     0

DataTypeMode: Fixed-point: binary point scaling
Signed: true
WordLength: 2
FractionLength: 0

Example 3

The functions ceil, fix, and floor differ in the way they round fi objects:

The following table illustrates these differences for a given fi object a.

aceil(a)fix(a)floor(a)
– 2.5–2–2–3
–1.75–1–1–2
–1.25–1–1–2
–0.500–1
0.5100
1.25211
1.75211
2.5322

See Also

ceil, convergent, fix, nearest, round

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS