Path: utzoo!attcan!uunet!samsung!zaphod.mps.ohio-state.edu!sunybcs!acsu.buffalo.edu From: chu@acsu.buffalo.edu (john c chu) Newsgroups: comp.lang.c Subject: Poorly worded question (was Re: IsUnsigned() function?) Message-ID: <31240@eerie.acsu.Buffalo.EDU> Date: 22 Jul 90 16:41:05 GMT References: <17125@haddock.ima.isc.com> <1990Jul20.144241.2560@diku.dk> <3566@sactoh0.UUCP> Sender: news@acsu.Buffalo.EDU Organization: SUNY Buffalo Lines: 46 Nntp-Posting-Host: autarch.acsu.buffalo.edu In article <3566@sactoh0.UUCP> jak@sactoh0.UUCP (Jay A. Konigsberg) writes: >dicovered that the correct answer is the simple one. Namely: >if ( num < 0 ) return FALSE else return TRUE; This is essentially Karl Heuer's return(num>=0) (or something to the effect, sorry) which was considered the trivial solution. >The question >is designed to find people who will make things overly complacted >or just don't know very much about how things work - thats where I >got traped. I passed by the simple solution because the question >seemed to imply that it wasn't the best. Oh well, thats why I read >this group. > >In fact, the systems programmer liked the question so much, he said >he was going to include it in his interviews in the future. The question seems designed to find people who will mis-read questions to find the easy way out. :-) Seriously, there are at least 3 valid interpretations of that question. The question originally stated that they wanted a function to return a 0 if an integer is signed or a 1 if it is unsigned. Interpretation 1: return a 0 if the integer is of type int, return a 1 if it is of unsigned int (this can only be done by macro, right?) Interpretation 2: return a 0 if the integer is less than zero, else return a 1 (this is what they wanted and has been called the trivial solution by the net). Interpretation 3: technically, all numbers are 'signed' (positive or negative) except 0, so it should return a 0 for all numbers except 0 for which it should return a 1. (e.g. return(num = 0)) I've come up with a new plausible interpretation each time I've read the original post (they came in the order listed above). IMHO, this question has too many interpretations to be a good question without some clarification. (Or perhaps it was intentional, so that they can find the people who think their way. I personally would have ended up implementing Interpretation 3.) john chu@autarch.acsu.buffalo.edu