Documentation

# Fixed-Point Basics in MATLAB

Fixed-point and half-precision numbers, scale, cast, precision, arithmetic operations

To assign a fixed-point data type to a number or variable in MATLAB®, use the `fi` object. In the `fi` constructor, you can specify other numeric type properties, such as word length and fraction length, and properties that control the arithmetic of fixed-point data.

## Functions

expand all

 `fi` Construct fixed-point numeric object `ufi` Construct unsigned fixed-point numeric object `sfi` Construct signed fixed-point numeric object `fimath` Set fixed-point math settings `fipref` Set fixed-point preferences `numerictype` Construct numerictype object `accumpos` Add two fi objects or values `accumneg` Subtract two fi objects or values `quantize` Quantize fixed-point numbers `bin` Binary representation of stored integer of fi object `dec` Unsigned decimal representation of stored integer of fi object `double` Double-precision floating-point real-world value of fi object `hex` Hexadecimal representation of stored integer of fi object `removefimath` Remove fimath object from fi object `setfimath` Attach fimath object to fi object `globalfimath` Configure global fimath and return handle object `removeglobalfimathpref` Remove global fimath preference `resetglobalfimath` Set global fimath to MATLAB factory default `storedInteger` Stored integer value of fi object `storedIntegerToDouble` Convert stored integer value of fi object to built-in double value
 `half` Construct half-precision numeric object `pow10` Base 10 power and scale half-precision numbers `rsqrt` Reciprocal square root `fma` Multiply and add using fused multiply add approach

## Classes

 `embedded.fi` Fixed-point numeric object `embedded.fimath` fimath object `embedded.numerictype` numerictype object

## Topics

Ways to Construct fi Objects

Teaches you how to create `fi` objects

Set Up Fixed-Point Objects

Basic information on using fi objects

Cast fi Objects

Shows you how to cast `fi` objects

Compute Slope and Bias

Describes slope-bias scaling and how to compute it

fi Object Properties

Tells you how to find more information about the properties associated with `fi` objects, and shows you how to set these properties

fi Objects and C Integer Data Types

Compares ANSI C integer data type ranges, conversions, and exception handling with those of `fi` objects

fi Object Display Preferences Using fipref

Gives examples of using `fipref` objects to set display preferences for `fi` objects

Underflow and Overflow Logging Using fipref

Gives examples of using `fipref` objects to set logging preferences for `fi` objects

Data Type Override Preferences Using fipref

Describes how to use the `fipref` object to perform data type override

Describes the ways you can use Fixed-Point Designer™ `fi` objects with Simulink® models

fi Objects with DSP System Toolbox

Describes how to pass fixed-point data back and forth between the MATLAB workspace and Simulink models using DSP System Toolbox™ blocks

## Troubleshooting

What Is the Difference Between Fixed-Point and Built-In Integer Types?

Explains the difference between fixed-point data types and built-in integer data types in MATLAB.

Negative Fraction Length

A negative fraction length occurs when the input value of a `fi` object contains trailing zeros.

Fraction Length Greater Than Word Length

A fraction length greater than the word length of a fixed-point number occurs when the number has an absolute value less than one and contains leading zeros.

Get trial now