Xref: utzoo misc.jobs.offered:2535 comp.lang.c:19608 Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!bloom-beacon!mcgill-vision!mouse From: mouse@mcgill-vision.UUCP (der Mouse) Newsgroups: misc.jobs.offered,comp.lang.c Subject: Re: 1000 lines of C a week? Message-ID: <1570@mcgill-vision.UUCP> Date: 27 Jun 89 09:53:54 GMT References: <15526@pollux.UUCP> <18783@vax5.CIT.CORNELL.EDU> <19436@cup.portal.com> Distribution: na Organization: McGill University, Montreal Lines: 38 In article <19436@cup.portal.com>, Tim_CDC_Roberts@cup.portal.com writes: > In <18783@vax5.CIT.CORNELL.EDU>, sc2y@vax5.cit.cornell.edu asks with > tongue in cheek: >>> A project needs a person with a proven capability of generating a >>> thousand lines of debugged C a week. >> Okay, how about this? >> /* compute square root of a number if less than 1000 */ >> float comp_sqrt(x) int x; { >> if (x == 1) >> return (sqrt(x)); >> .... > Since you didn't declare "double sqrt (double)", If we're being picky, he also didn't say the code he exhibited was the entire file: it could have been just one routine extracted from a file which quite possibly had a line "#include " above the sample. > and you are passing an int to a function expecting a double, and > returning a double for a function that is supposed to return a float, > this function will fail on any machine where sizeof(int) != > sizeof(double) or sizeof(float) != sizeof(double). Actually (under the assumptions you made, ie, no declarations), it requires more than just that int and double have the same size - it also requires that for all values 1 to 999, the bit patterns are identical and are passed to sqrt() in the same way. (I expect this excludes all existing C compilers. I certainly *hope* it does!) The "returning a double when supposed to return a float" is specious: return values have always been cast to the proper type for the function, even in Classic C. der Mouse old: mcgill-vision!mouse new: mouse@larry.mcrcim.mcgill.edu