Stateflow User's Guide Previous page   Next Page

Fixed-Point Numbers

Fixed-point numbers use integers and integer arithmetic to represent real numbers and arithmetic with the following encoding scheme:

where

Fixed-point numbers encode real quantities (for example, 15.375) using the stored integer . You set 's value by solving the preceding equation for and rounding the result to an integer value as follows:

For example, suppose you want to represent the number 15.375 in a fixed-point type with the slope and the bias. This means that

However, because is rounded to an integer, you have lost some precision in representing the number 15.375. If you calculate the number that actually represents, you now get a slightly different answer.

So using fixed-point numbers to represent real numbers with integers involves the loss of some precision. However, if you choose and correctly, you can minimize this loss to acceptable levels.


Previous page  What Is Fixed-Point Data? Fixed-Point Operations Next page

© 1994-2005 The MathWorks, Inc.