IsUnsigned() function?

Doug McDonald mcdonald at aries.scs.uiuc.edu
Mon Jul 23 01:43:26 AEST 1990


In article <2936 at mtung.ATT.COM> rdh at mtung.ATT.COM (Ralph Hayon) writes:
>How about this:
>
>	IsUnsigned (a) 

IS what is wanted here a decision as to the **TYPE** of the variable,
signed or unsigned? I assume so. Then I don't see how a function is
possible at all. IT has to have a defined type parameter. Period.

On the other hand a macro should be possible on any given machine.
But can a portable one be written? Portable to any size int (16 bit,
18 bit, 32 bit, 60 bit, 64 bit...), and to ones or twos complement
(sign-magnitude?). This seems like an interesting and useful topic
for comp.lang.c. 

To extend it a bit, how about macros for

is_twos_complement()

is_ones_complement()

word_size(a), which returns the number of bits in a


Doug McDonald



More information about the Comp.lang.c mailing list