Designing Your Model: Model-Code Correspondence : Fixed-Point Variable Support : Fixed-Point Variable Implementation Method

Fixed-Point Variable Implementation Method

The Rational Statemate MicroC Code Generator uses the “2 factorials” implementation method—redefining the least significant bit (LSB) to represent zero, or the negative power of 2. This implementation is not the most accurate method but it provides reasonable code size and runtime performance.

For example, take the binary 8-bit value 0b00010001. Usually, the value represented here is “17”:

The 5th bit corresponds to 24 (16).
Rescaling this value to begin at 2-3 gives: 2.125 = 1*2-3 (or 0.125) + 1*21 (or 2)

The parameter required here is the power (of 2) represented by the LSB. This is also the resolution.