National Instruments AutoCode NI MATRIX User Manual

Page 54

Advertising
background image

Chapter 2

C Language Reference

© National Instruments Corporation

2-37

AutoCode Reference

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

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

rp

bits, and with overflow protection is:

iALIGNubp(n,rp)

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

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

rp

bits, and with overflow protection is:

sbALIGNip(n,rp)

n = Fixed-point operand to align

i ALIGN so wo p (n, rp)

rp = Number of bits to shift

p = Overflow protection (optional)

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

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

ALIGN (indicates conversion)

i = Indicates integer result

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

n = Fixed-point operand to align

sr wr ALIGN i p (n, rp)

rp = Number of bits to shift

p = Overflow protection (optional)

i = Indicates integer input

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)

Advertising