chu@acsu.buffalo.edu (john c chu) (07/22/90)
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
chu@acsu.buffalo.edu (john c chu) (07/23/90)
In article <31240@eerie.acsu.Buffalo.EDU> chu@acsu.buffalo.edu (john c chu) writes: >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)) Of course I meant return(num==0) I'm so ashamed... john chu@autarch.acsu.buffalo.edu
volpe@underdog.crd.ge.com (Christopher R Volpe) (07/23/90)
|>In article <31240@eerie.acsu.Buffalo.EDU> chu@acsu.buffalo.edu (john c chu) writes: |>>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)) All numbers are 'signed' except zero? Does that mean a variable declared as "unsigned int" should hold only the value zero? May as well use a constant. :-) -Chris Volpe
johnb@srchtec.UUCP (John Baldwin) (07/24/90)
I vote that we appoint someone to call the interviewer and find out what he REALLY wanted, and what he REALLY hoped to accomplish. I'm really curious: is this guy one of the cleverest interviewers around, or is he an unmitigated bozo? (I'm sure there are those of us who may make negative choices WRT relationships with you-know-who-corp, if their people don't have a Real Good Reason for doing this sort of thing.) (Standard disclaimer: opinion is my very own, thank you.) -- John T. Baldwin | Disclaimer: search technology, inc. | Some people claim I never existed. Norcross, Georgia | (real .sig under construction johnb@srchtec.uucp | at Starfleet Orbital Navy Yards ;-)