Main Content

Fixed-Point Numbers in Simulink

Simulink® data type names must be valid MATLAB® identifiers with less than 128 characters. The data type name provides information about container type, number encoding, and scaling.

You can represent a fixed-point number using the fixed-point scaling equation

VV~=SQ+B,

where

  • V is the real-world value.

  • V~ is the approximate real-world value.

  • S = F2E is the slope.

  • F is the slope adjustment factor, where F is a value in the range [1.0, 2.0).

  • E is the fixed power-of-two exponent.

  • Q is the stored integer.

  • B is the bias.

Fixed-Point Data Type and Scaling Notation

The following table provides a key for various symbols that appear in Simulink products to indicate the data type and scaling of a fixed-point value.

Symbol

Description

Example

Container Type

ufix

Unsigned fixed-point data type

ufix8 is an 8-bit unsigned fixed-point data type

sfix

Signed fixed-point data type

sfix128 is a 128-bit signed fixed-point data type

fltu

Scaled Doubles override of an unsigned fixed-point data type (ufix)

fltu32 is a scaled doubles override of ufix32

flts

Scaled Doubles override of a signed fixed-point data type (sfix)

flts64 is a scaled doubles override of sfix64

Number Encoding

e

10^

125e8 equals 125*(10^(8))

n

Negative

n31 equals -31

p

Decimal point

1p5 equals 1.5

p2 equals 0.2

Scaling Encoding

S

Slope

ufix16_S5_B7 is a 16-bit unsigned fixed-point data type with Slope of 5 and Bias of 7

B

Bias

ufix16_S5_B7 is a 16-bit unsigned fixed-point data type with Slope of 5 and Bias of 7

E

Fixed exponent (2^)

A negative fixed exponent describes the fraction length

sfix32_En31 is a 32-bit signed fixed-point data type with a fraction length of 31

F

Slope adjustment factor

ufix16_F1p5_En50 is a 16-bit unsigned fixed-point data type with a SlopeAdjustmentFactor of 1.5 and a FixedExponent of -50

C, c, D, or d

Compressed encoding for Bias

Note

If you pass this symbol to the slDataTypeAndScale function, it returns a valid fixdt data type.

No example available. For backward compatibility only.

To identify and replace calls to slDataTypeAndScale, use the Check for calls to slDataTypeAndScale Model Advisor check.

T or t

Compressed encoding for Slope

Note

If you pass this symbol to the slDataTypeAndScale, it returns a valid fixdt data type.

No example available. For backward compatibility only.

To identify and replace calls to slDataTypeAndScale, use the Check for calls to slDataTypeAndScale Model Advisor check.

Related Topics

Go to top of page