Bug or Feature?
© 2012 By: Dov Trietsch. All rights
reserved.
I was born in a time and place where avant-garde accountants used a
handle-powered adding machines, old-fashioned ones still used pencil and paper,
and all used their heads. As a child I did most of my calculations mentally and
reverted to paper and pencil only for the really tough ones. As a young
statistician I did most of my calculations on an Electro-mechanical calculator
which had the ability to do the sum of x while computing the sum of
x^{2.} This feature on my "Facit" really facilitated my work because the
two sums are needed to compute the average and standard deviation.. I also
learned to program computers, but I still do most calculations in my head.
When my daughter started elementary school, the HP hand-held scientific
calculator was two years old and K&E stopped making slide
rules. When she reached second grade, TI released its "Professor" – an owl
shaped hand-held calculator that could also be used to give a child an
arithmetic quiz. Almost every kid in her class owned one of these owls and she
wanted one badly. Like a banker who’ll only lend money to those who don’t need
it, I refused her. "When you know your arithmetic down pat," I said "and need to
do really complex computations, I’ll buy you one." Seven years later, for her
honors physics lab, I bought her a programmable scientific calculator. Ours, I
am proud to say, was a Spartan home. We still don’t have cable TV, we never had
any video games and for her personal computer our daughter had to program her
own games. She realized, after successfully programming her first Dungeons and
Dragons game that she does not particularly like programming, but she was
exposed to the art at a very young age and her computer generated game scenarios
always drew a crowd of youngsters to our home.
Yesterday, contrary to my habits, I used the Windows' Calculator and out of curiosity used the
various keys and buttons. One such button - Int - calculates
the integer part of a number. Its inverse - Frac calculates
the fractional part. Again, out of curiosity, I tried them both on the number
(-5.7). The results were -5 and -0.7 respectively. For 5.7 the result were 5 and
0.7 respectively. This is wrong! Worse, most of today’s young adults, who never
mastered arithmetic (because they owned a "professor" or a similar crutch), use
the Windows Calculator as a gospel. To them it must be right.
Why is it wrong? The Int function returns the highest integer that is lower
or equal to a number. Int(5.7) is indeed 5. Int(-5.7) is (-6). (-5) is greater
than (-5.7). The fractional part is even more complex. Again for 5.7 the result
is indeed 0.7. For (-5.7) the result is 0.3. Yes 3/10ths! Why? The sum of
integer and fraction make the number. 5 + 0.7 = 5.7. Similarly (-6) + 0.3 =
(-5.7).
Even at Microsoft they know better. Here is How Excel applies the INT
function: =INT(-5.7) returned the correct answer of
-6. Excel does not have the Frac function so
it could not be tested.
I first noticed this bug in the good old days of Win 3.1.
During the years, I have revisited the calculator now and then. At least 17
years have passed. Operating systems came and went. We are now using Windows 7
(8 is just around the corner), but the Int nad
Frac error persists. By now it had become a tradition and we
all know that tradition is stronger than science. When will they ever
learn?!
That's All Folks