{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lecture09a - 0306-381 Applied Programming Fixed-Point(Q...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
0306-381 Applied Programming Fixed-Point (Q Number) Arithmetic Numerical Derivative
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
• Data type to meet needs of application • Range (Q Q in N -bit word) –Signed: [ - 2 N - 1 - Q , 2 N - 1 - Q - 2 - Q ] –Unsigned: [0, 2 N - Q - 2 - Q ] • Resolution –Smallest possible value –2 - Q –Uniform across entire range Q-Format Characteristics 2 Unlike FP
Background image of page 2
Convert from float to Q Q –Need to multiply floating-point value by 2 Q and store in an N -bit integer –C code float NumFloat; Q Q NumQ Q ; NumQ Q = (Q Q ) (NumFloat * (float) (1 << Q )); Q-Format Conversion: from Float 3 –C macro #define FLOAT_TO_Q Q (X) ((Q Q ) (X * (float) (1 << Q )))
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Convert from Q Q to float –Need to divide N -bit integer value by 2 Q and store in a floating-point number, making sure Q -bit fractional result is kept –C code float NumFloat; Q Q NumQ Q ; NumFloat = (float) NumQ Q / (float) (1 << Q )); Q-Format Conversion: to Float 4 –C macro #define Q Q _TO_FLOAT(X) ((float) X / (float) (1 << Q ))
Background image of page 4
Add two Q Q numbers: C = A + B –Need to add two N -bit integers and store result in an N -bit integer –C code Q Q A, B, C; C = A + B; Q-Format Addition 5 –C macro #define Q Q _ADD(A,B) ((A) + (B))
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}