Newsgroups: comp.lang.c Path: utzoo!telly!robohack!druid!darcy From: darcy@druid.uucp (D'Arcy J.M. Cain) Subject: Re: IsUnsigned() function? Message-ID: <1990Jul18.001326.5728@druid.uucp> Organization: D'Arcy Cain Consulting, West Hill, Ontario References: <1990Jul16.214155.5087@Neon.Stanford.EDU> Date: Wed, 18 Jul 90 00:13:26 GMT In article <1990Jul16.214155.5087@Neon.Stanford.EDU> jhsu@Neon.Stanford.EDU (Jeffrey H. Hsu) writes: > Here is a C question I was asked at a Microsoft interview (no, I didn't >get the job...). > How would you write a space efficient algorithm/function in C that >takes in an integer and returns 0 if signed and 1 if unsigned? > IsUnsigned(a) > int a; > { > } How about: #define IsUnsigned(a) 0 Since your declaration says that a is an int then you are saying it is always signed. -- D'Arcy J.M. Cain (darcy@druid) | Government: D'Arcy Cain Consulting | Organized crime with an attitude West Hill, Ontario, Canada | (416) 281-6094 |