From: Dr Ivan D. Reid on
On Mon, 31 May 2010 16:29:38 +1200, Gib Bogle <g.bogle(a)auckland.no.spam.ac.nz>
wrote in <htvdvh$nmq$2(a)speranza.aioe.org>:
> mecej4 wrote:
>> Elaheh wrote:

>> On your electronic calculator, carry out the following calculation exactly
>> as shown, see what the result is, and try to explain why it came out that
>> way:

>> (4.0/3.0 - 1.0)*3.0 - 1.0

> My electronic calculator (Aurora SC190) gave the answer 0. I can't explain why
> it came out this way.

Both my Poundland[1] scientific calculators give 0. -- my old
[(hp)] 21 (recently revived with a Poundland pack of NiMH AAs) gives
1.0000000e-09. Hmm, Windows XP calculator gives 0. as well.

[1] *Don't* ask how much they cost...

--
Ivan Reid, School of Engineering & Design, _____________ CMS Collaboration,
Brunel University. Ivan.Reid@[brunel.ac.uk|cern.ch] Room 40-1-B12, CERN
KotPT -- "for stupidity above and beyond the call of duty".
From: Gib Bogle on
JWM wrote:

>>
>> My electronic calculator (Aurora SC190) gave the answer 0. I can't
>> explain why it came out this way.
>
> Maybe because it's set to display the answer in fixed-point format?

I don't know how to set it to display results in different formats. Currently
it displays 10 significant figures (e.g. pi = 3.141592654), which is always
plenty for my purposes. My point, of course, was that if the OP has a
calculator like mine he wouldn't be any the wiser.
From: Arjen Markus on
On 31 mei, 06:29, Gib Bogle <g.bo...(a)auckland.no.spam.ac.nz> wrote:
> mecej4 wrote:
> > Elaheh wrote:
> > On your electronic calculator, carry out the following calculation exactly
> > as shown, see what the result is, and try to explain why it came out that
> > way:
>
> >    (4.0/3.0 - 1.0)*3.0 - 1.0
>
> My electronic calculator (Aurora SC190) gave the answer 0.  I can't explain why
> it came out this way.

Don't electronic calculators use a different technique for computing?
IEEE-854
which allows a radix of 10 instead of IEEE-754? That will give
different results.
Plus it may of course use extended precision, another source for
subtly different
results.

Regards,

Arjen
From: mecej4 on
Gib Bogle wrote:

> mecej4 wrote:
>> Elaheh wrote:
>
>> On your electronic calculator, carry out the following calculation
>> exactly as shown, see what the result is, and try to explain why it came
>> out that way:
>>
>> (4.0/3.0 - 1.0)*3.0 - 1.0
>
> My electronic calculator (Aurora SC190) gave the answer 0. I can't
> explain why it came out this way.

To obtain the explanation, you would need information on how the calculator
performs arithmetic.

In the early days of electronic calculators becoming commonly available,
many of the manufacturers provide fairly detailed manuals. Now, you may
need to go to the mfr's Web site to look for a technical manual.

Here is the same example, carried out using an interpreted language on a PC.
If you have Python, Ruby or something of the sort, try:

$ python
Python 2.6 (r26:66714, Mar 30 2010, 00:29:28)
[GCC 4.3.2 [gcc-4_3-branch revision 141291]] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> (4.0/3.0-1.0)*3.0-1.0
-2.2204460492503131e-16
>>>

which is the same as what you get in Fortran for

WRITE(*,*)-EPSILON(1.0D0)

-- mecej4
From: Ron Shepard on
In article <hu0as7$tao$1(a)news.eternal-september.org>,
mecej4 <mecej4.nyetspam(a)operamail.com> wrote:

> >> (4.0/3.0 - 1.0)*3.0 - 1.0
> >
> > My electronic calculator (Aurora SC190) gave the answer 0. I can't
> > explain why it came out this way.
>
> To obtain the explanation, you would need information on how the calculator
> performs arithmetic.

This is right. This is a topic that is discussed fairly often among
numerical analysis and algorithms people. But it usually has more
to do with how results are displayed than how the arithmetic is
actually done.

When digital calculators first became available to the general
public in the mid 1970's, many people thought it was odd that the
result from such expressions did not result in zero being displayed.
To "fix" this problem, the displayed results were rounded so that
the last two or three bits of the result were ignored. The problem,
of course, is that the calculator does not know when those last
digits are significant and when they aren't. All displayed results
are rounded in this manner so both correct and incorrect digits are
truncated. Some calculator manufacturers (including HP) produced
what they called "scientific" calculators that had displays using
scientific notation (along with special functions and so on), and
they chose to display the results to full precision. This places
the burden on the user to determine which digits are significant and
which ones aren't.

Newer calculators, since the 1980's, sometimes have symbolic algebra
capabilities. I have an HP calculator from about 1990 like this.
It does some calculations like the above in symbolic form, gets the
correct answer for the correct reason, and then displays the results
of that symbolic calculation correctly. So if the calculation is
performed symbolically until the display is determined at the very
end, then "0" is the correct result that should be displayed. If
the calculation is done in floating point arithmetic, then some
small number (e.g. 1.e-9, 1.e-12, or 1.e-16, depending on the
precision) is the correct result that should be displayed, where
"correct" means the closest decimal number to the computed binary
digital result. If your calculator computes the result with
floating point, but displays "0", then it is not showing you the
full precision possible that it has computed.

$.02 -Ron Shepard