Academic Program

Numerical Formats

Numerical Formats

Integer/Fractional Relationship

The same two's complement N-bit word may represent an integer value or a fractional value. The same arithmetic and logic hardware may be used with either format. We just interpret the results differently.

(1) xFRACTION=xINTEGER/2N1

(2) xINTEGER=xFRACTION2N1

For N = 16 bits, 2N-1 = 32768

Word
Value
Integer
Value
Fractional
Value
0x8000 -32768 -1.000000
0xA000 -24576 -0.750000
0xC000 -16384 -0.500000
0xE000 -8192 -0.250000
0x0000 0 0.000000
0x2000 8192 0.250000
0x4000 16384 0.500000
0x6000 24576 0.750000
0x7FFF 32767 0.999969
IntFrac.png

 

1.15(Q15) Signed Fractional Format

SignedFrac.png

 

To understand how Q15 numbers are handled, let's assume we have a 16-bit integer in 2's complement format where s is a sign bit and an is the digit at bit n.

(3) a = <sa14a13...a1a0>

For a positive integer a, the value of the number a is:

(4) a = a14214+a13213+...+a121+a020

For a Q15 number, the weightings of each bit change. Let b = a / 215, then the value of a positive Q15 number b is:

(5) b = a1421+a1322+...+a1214+a0215

The maximum negative value that can be handled is 0x8000 = -1.000000000000 and the maximum positive value is 0x7FFF = 0.999969482422. Zero is represented by 0x0000.

For more information on the Q format see this Wikipedia article.