Re: This calculation is just wrong / computer can't count!
"Michael K. O'Neill" <mikeathon2000@nospam.hotmail.com> wrote in message
news:Og7fRJvCIHA.5044@TK2MSFTNGP03.phx.gbl...
I don't agree with that analogy, and I don't see any reason to agree with
GT's complaint.
It's not a stark question of black vs. white as in your example.
It's closer to a situation in which GT is trying to calculate the gray
level
of a pixel as 255*0.833333333(3, repeating), and whereas he is getting an
answer of 212.5, the computer's answer is 213 and thus must obviously be
wrong.
Actually, 213 is reasonably close to 212.5, so GT is not objecting to this.
Now if the calculation returned 215 instead of 213, we could all agree that
is wrong. And that is like what GT is seeing with the 0.33333...7.
For our part, we try to explain that because the gray level of a
pixel must be an integer, that there is simply not number between 212 and
213. We further explain the integer numbering system, and that it is a
discrete numbering system rather than a continuous real numbering system,
and that the answer of 213 is correct to +/- 1/2 a binary LSB. We provide
references and examples to make this understandable. We offer alternative
algorithms to make his algorithm more robust and to make the apparent
error
invisible to the user. All this makes sense to all of us, but GT refuses
to
understand it. He also refuses to get past his incorrect position that
because he calculates a number that's different from that calculated by
the
computer, that the computer is wrong, that everyone else is wrong, and
that
nobody is paying attention to his view of the world which to him is
obviously the only correct view.
Well, I think the view common to some C++ programmers is not entirely
accurate. We tend to elevate the computer's binary system to sainthood - on
an even par with human's decimal system. This is geeky to say the least,
and most people do not do this. After all, we only tolerate the binary
system because that is what computers use, and computers tend to be useful
to humans. And when the binary system does not suit human needs, it should
be considered wrong. GT is right that because the computer calculates a
number differently than what is useful to humans, the computer is wrong.
There's a saying, "the abstraction leaks." (credit Joel On Software).
There's another saying that a program "has a UI only it's designer could
love". Paraphrasing, "IEEE floating point math is something only geeks
could love." IOW, it has its warts, but people here are ignoring them.
Close the bug AS DESIGNED. :-)
I pity his co-workers and his end users. He mentioned elsewhere that he
is
writing some sort of a scheduling program, and I hope I never have the
misfortune of being saddled with it, or of considering the payment of
money
for it.
Actually, I think GT is the one who cares more about his end users. He's
the one who would write an app that displays 0.33333 instead of 0.33337. I
really think some of the people on this thread would have their app display
0.33337 and then add a section in their README file that says their app
displays IEEE floating point results, so any discrepency with a $1
calculator is AS DESIGNED. (That's somewhat a joke, but only somewhat.)
GT: several solutions are offered, but here's my drift: use double and
then use CString::Format() to print only a few digits, and that's it.
-- David