National Instruments AutoCode NI MATRIX User Manual

Page 53

Advertising
background image

Chapter 2

C Language Reference

AutoCode Reference

2-36

ni.com

Figures 2-6 through 2-8 show how the conversion macros are named.
Notice that macro names have no embedded spaces.

Figure 2-6. AutoCode/C Conversion Macros for Fixed-to-Fixed Conversions

For example, the macro to convert an unsigned 8-bit number to a signed
8-bit number with a shift of

rp

bits, and with overflow protection is:

sbALIGNubp(n,rp)

n = Fixed-point operand to align

sr wr ALIGN so wo p q(n, rp)

rp = Number of bits to shift

q = optional answer quantization (r, c, or f)

p = Overflow protection (optional)

wo = Operand wordsize (b=byte, s=short, l=long)

so = Operand sign (u=unsigned, s=signed)

ALIGN (indicates conversion)

wr = Result wordsize (b=byte,

s=short, l=long)

sr = Result sign (u=unsigned, s=signed)

(if rp < 0, perform a left-shift;
if rp > 0, perform a right-shift)

r = round the answer
c = ceiling the answer
f = floor the answer
default (no r, c, or f) is truncate the answer

NOTE: The operand wordsize must be equal

to or larger than the result wordsize

(see NOTE above)

Advertising