This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Scaling, Precision, and Range

The dynamic range of fixed-point values is less than floating-point values with equivalent word sizes. To avoid overflow and minimize quantization errors, fixed-point numbers must be scaled.

Scaling

With Fixed-Point Designer™, you can select a fixed-point data type whose scaling is defined by its binary point, or you can select an arbitrary linear scaling that suits your needs.

Slope and Bias Scaling

You can represent a fixed-point number by a general slope and bias encoding scheme. The real world value of a slope bias scaled number can be represented by:

real-world value=(slope×integer)+bias

slope=slope adjustment factor×2fixed exponent

The slope and bias together represent the scaling of the fixed-point number. In a number with zero bias, only the slope affects the scaling. A fixed-point number that is only scaled by binary point position is equivalent to a number in slope bias representation that has a bias equal to zero and a slope adjustment factor equal to one. This is referred to as binary point-only scaling or power-of-two scaling.

Binary-Point-Only Scaling

Binary-point-only or power-of-two scaling involves moving the binary point within the fixed-point word. The advantage of this scaling mode is to minimize the number of processor arithmetic operations. The real world value of a binary-point only scaled number can be represented by:

real world value=2fraction length×integer

Precision

The precision of a fixed-point number is the difference between successive values representable by its data type and scaling, which is equal to the value of its least significant bit. The value of the least significant bit, and therefore the precision of the number, is determined by the number of fractional bits. A fixed-point value can be represented to within half of the precision of its data type and scaling.

For example, a fixed-point representation with four bits to the right of the binary point has a precision of 2-4 or 0.0625, which is the value of its least significant bit. Any number within the range of this data type and scaling can be represented to within (2-4)/2 or 0.03125, which is half the precision.

Rounding Methods

When you represent numbers with finite precision, not every number in the available range can be represented exactly. If a number cannot be represented exactly by the specified data type and scaling, a rounding method is used to cast the value to a representable number. Although precision is always lost in the rounding operation, the cost of the operation and the amount of bias that is introduced depends on the rounding method itself. For more information on the rounding methods available with Fixed-Point Designer, see Rounding Methods (Fixed-Point Designer)

Range

Range is the span of numbers that a fixed-point data type and scaling can represent. The range of representable numbers for an unsigned two’s complement fixed-point number of word length ws, scaling S, and bias B is illustrated below:

The following figure illustrates the range of representable numbers for a two’s complement signed fixed-point number:

For both signed and unsigned fixed-point numbers of any data type, the number of different bit patterns is 2wl.

For example, in two’s complement, negative numbers must be represented as well as zero, so the maximum value is 2wl-1-1. Because there is only one representation for zero, there are an unequal number of positive and negative numbers. This means there is a representation for —2wl-1, but not for 2wl-1.

Related Topics