[NTLUG:Discuss] The wrong computation example from the newsgroup
Chris Cox
cjcox at acm.org
Sat Mar 17 23:05:08 CST 2001
Here's the original problem... for those NTLUGgers who want a challenge.
> From: John Smith (jmsith at generic.com)
> Subject: Can linux be trusted?
> Newsgroups: comp.lang.c, comp.os.linux.development.apps, comp.os.linux.development.system, comp.sys.be.programmer,
> comp.sys.mac.programmer.misc, comp.unix.bsd.freebsd.misc, comp.unix.bsd.misc, gnu.gcc
> Date: 2001-02-28 17:52:12 PST
>
>
>
> "
> If you've got a minute, and one of those 'bleeding edge' OSes, try compiling
> with no optimizations and running this for fun:
>
> int main(void)
> {
> int a = 60, b = 6, c = 10;
>
> printf("%d = %d\n", (int) (((60/6)*0.3) + (10*0.7)), (int) ((( a/b)*0.3) +
> ( c*0.7)));
>
> exit(1);
> }
>
> (BTW the lameness filter defies logic, that was the best I could do with the
> C snippet)
>
> A friend was tortured for a few hours doing an assignment until I took a
> look at the code and realized the problem boiled down to something that can
> be reduced to this snippet.
>
> I compiled this with default compiler settings on every platform I could
> find. This means Digital Unix 4.0, OpenVMS 7.2, Solaris 8, IRIX 6.4, HP-UX
> 10.20, FreeBSD 4-STABLE, OpenBSD 2.8 and various Linux distros, from ancient
> to cutting edge - both with gcc and any commercial compilers that happened
> to be available at each box.
>
> On all Linux distros, and only on Linux distros, ranging from an ancient
> Slackware setup to the latest Red Hat, I get 9=10. On everything else, I get
> 10=10. Go figure, and remember that the whole OS is compiled with that.
>
> I think I'll just stick to FreeBSD as far as my intel boxes are concerned.
> "
> http://slashdot.org/comments.pl?sid=01/02/28/1712232&cid=93
>
More information about the Discuss
mailing list