[NTLUG:Discuss] The wrong computation example from the newsgroup
Steve Baker
sjbaker1 at airmail.net
Mon Mar 19 20:41:01 CST 2001
m m wrote:
>
> you guys are so smart, know all the details of these stuff, and do not think
> it is a problem (because of the architecture of computer, the complier....)
> Question here: for those who are not a programmer or just know how to use
> computer, Linux can still be trusted?
Yes - the conclusion is that the example program is "broken" in a fundamental
way - and Linux is doing *exactly* the right thing...so are the other compilers.
Providing the result is either: 9==9, 9==10, 10==9 or 10==10, you have valid,
legal, correct C compiler. The example program simply doesn't have a well-defined
output...it's the example program that's broken.
> in other words, if I am going to use Linux for business, and I have do
> computation like the example...
You should *never* have to do that calculation...bear in mind, it only
seems strange because of the way it truncates the result.
> and I got wrong result. I think it may not
> acceptable, people are looking for a reliable computers (OSs). shouldn't
> this problem be fixed? (remember it only happen on Linux box)
> Don't upset, I am just in the view point of a regular user.
Look - just don't worry. Trust an expert here. I've written many millions
of lines of code over several decades - and I can absolutely assure you that
there is nothing whatever to be concerned about. This is just how computers
are...ALL COMPUTERS. If they'd picked slightly different numbers, they could
have tricked any of the other systems into *seemingly* producing a 'bad' result.
Programmers of any system, be it Linux, BSD, Windoze or MacOS, have to be
careful not to make assuptions like the author of that snippet of code
did...when you are moderately careful it's never a problem.
Linux and GCC worked perfectly...no mistake was made apart from in the
mind of the person who fabricated the problem.
--
Steve Baker HomeEmail: <sjbaker1 at airmail.net>
WorkEmail: <sjbaker at link.com>
HomePage : http://web2.airmail.net/sjbaker1
Projects : http://plib.sourceforge.net
http://tuxaqfh.sourceforge.net
http://tuxkart.sourceforge.net
http://prettypoly.sourceforge.net
http://freeglut.sourceforge.net
More information about the Discuss
mailing list