Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!brutus.cs.uiuc.edu!ux1.cso.uiuc.edu!aries!mcdonald From: mcdonald@aries.scs.uiuc.edu (Doug McDonald) Newsgroups: comp.lang.c Subject: Re: IsUnsigned() function? Message-ID: <1990Jul22.154326.19680@ux1.cso.uiuc.edu> Date: 22 Jul 90 15:43:26 GMT References: <1990Jul16.214155.5087@Neon.Stanford.EDU> <2936@mtung.ATT.COM> Sender: usenet@ux1.cso.uiuc.edu (News) Reply-To: mcdonald@aries.scs.uiuc.edu (Doug McDonald) Organization: School of Chemical Sciences, Univ. of Illinois at Urbana-Champaign Lines: 25 In article <2936@mtung.ATT.COM> rdh@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