Fixed-Point Arithmetic

How the software performs fixed-point arithmetic operations, effects of data type and scaling

Fixed-point arithmetic refers to how signed or unsigned binary words are operated on. The simplicity of fixed-point arithmetic functions such as addition and subtraction allows for cost-effective hardware implementations.

Topics

Fixed-Point Arithmetic

Addition, subtraction, multiplication, casts, modulo and two’s complement arithmetic

Rules for Arithmetic Operations

Describes the rules that the Simulink® software follows when arithmetic operations are performed on inputs and parameters.

Shifts

Nearly all microprocessors and digital signal processors support well-defined bit-shift operations for integers.

Conversions and Arithmetic Operations

Provides an example highlighting the way the data types are converted and arithmetic operations are performed on inputs and parameters in the Simulink software

The Summation Process

Addition is the most common arithmetic operation a processor performs. When two n-bit numbers are added together, it is always possible to produce a result with n + 1 nonzero digits due to a carry from the leftmost digit.

The Multiplication Process

The multiplication of an n-bit binary number with an m-bit binary number results in a product that is up to m + n bits in length for both signed and unsigned words.

The Division Process

The C programming language provides access to integer division only for fixed-point data types. Depending on the size of the numerator, you can obtain some of the fractional bits by performing a shift prior to the integer division.

fimath Properties Usage for Fixed-Point Arithmetic

Using fimath objects to control the results of fixed-point arithmetic with fi objects.

Featured Examples