Path: utzoo!utgpu!watserv1!watmath!att!dptg!mtunh!netnews From: netnews@mtunh.ATT.COM (netnews dptg) Newsgroups: comp.lang.c Subject: Re: IsUnsigned() function? Message-ID: <2936@mtung.ATT.COM> Date: 20 Jul 90 04:12:28 GMT References: <1990Jul16.214155.5087@Neon.Stanford.EDU> Reply-To: rdh@mtung.ATT.COM (Ralph Hayon) Organization: AT&T Bell Laboratories, Middletown, NJ, USA Lines: 37 How about this: IsUnsigned (a) int a; { return( !(a >> ((sizeof(int)*8)-1))); } The only real assumption that this function makes is that there are 8 bits in a byte (a fair assumption I think). If you don't care about portability (I do, though) and like to make more assumptions (like the size of the int on your system) you can make it even shorter: 4 byte int: IsUnsigned (a) int a; { return( !(a >> 31)); } 2 byte int: IsUnsigned (a) int a; { return( !(a >> 15)); } BTW: What you have experienced says much more about Microsoft than about yourself. Don't let it eat you. Ralph Hayon AT&T Bell Laboratories, Middletown, NJ