{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lecture09a

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

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

0306-381 Applied Programming Fixed-Point (Q Number) Arithmetic Numerical Derivative

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

View Full Document
• 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
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 )))

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

View Full Document
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 ))
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))

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}