Path: utzoo!attcan!uunet!seismo!ukma!rutgers!mit-eddie!bu.edu!orc!decwrl!bacchus.pa.dec.com!shlump.nac.dec.com!tkou02.enet.dec.com!diamond From: diamond@tkou02.enet.dec.com (diamond@tkovoa) Newsgroups: comp.lang.c Subject: Re: IsUnsigned() function? Message-ID: <1859@tkou02.enet.dec.com> Date: 17 Jul 90 07:13:25 GMT References: <1990Jul16.214155.5087@Neon.Stanford.EDU> Reply-To: diamond@tkou02.enet.dec.com (diamond@tkovoa) Organization: Digital Equipment Corporation Japan , Tokyo Lines: 29 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 ________t interview > 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; > { > } Uh, maybe /* Remember first to #define signed or #define unsigned. */ IsUnsigned(a) #ifdef signed int a; #else unsigned a; #endif { #ifdef signed return 0; #else return 1; #end } Doesn't sound like a job that a programmer would want..... -- Norman Diamond, Nihon DEC diamond@tkou02.enet.dec.com This is me speaking. If you want to hear the company speak, you need DECtalk.