comp.lang.ada
 help / color / mirror / Atom feed
From: Keith Thompson <kst@cts.com>
Subject: Re: Ada and Java. different behaviour. casting long to int problem.
Date: 1999/06/15
Date: 1999-06-16T06:53:11+00:00	[thread overview]
Message-ID: <yecyahk4ox7.fsf@king.cts.com> (raw)
In-Reply-To: 3766D1CC.D712895E@itools.symantec.com

D'Arcy Smith <nospam@itools.symantec.com> writes:
> If you're sent into a room that is full of pins sticking up from the
> floor - and you are told that it is full of pins - and you run into
> the room with your eyes closed then it is 100% your fault.

(I took the liberty of correcting some typos in the quoted text.)

If I hire someone to build me a house, and the living room is full of
pins sticking up from the floor -- and the builder clearly tells me
about this feature -- it's my fault if I run into the living room with
my eyes closed.  But I'm going to be a bit upset with the builder for
building it that way in the first place.

No programming language implementation can accurately and efficiently
model arithmetic on the full set of mathematical integers.  (If it
can't handle 10**(10**(10**100)), it's not modeling the full
mathematical set.)  So, some compromises are necessary, typically by
guaranteeing mathematical correctness only for a limited range (32
bits, 64 bits, whatever).  My favorite compromise is the one that
says:

    For any arithmetic operation on integers, you will get the
    mathematically correct result if it fits in the representation;
    otherwise, you will be clearly informed that the implementation
    was unable to do so (via an exception or some similar mechanism).

For most purposes, I believe this is *better* than a compromise that
says,

    For any arithmetic operation on integers, you will get the
    mathematically correct result if it fits in the representation;
    otherwise, you will get a mathematically incorrect (but perhaps
    well-defined) result, with no straightforward way to detect that
    it's mathematically incorrect.

This assumes, of course, that the abstraction you're trying to
(partially) model is the mathematical set of integers -- which it
usually is.  Some people have argued that wraparound semantics, if
they're well-defined, are as "correct" as anything else.  Sorry, but I
don't buy it.

-- 
Keith Thompson (The_Other_Keith) kst@cts.com  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center  <http://www.sdsc.edu>                 <*>
One of the great tragedies of ancient history is that Helen of Troy
lived before the invention of the champagne bottle.




  reply	other threads:[~1999-06-15  0:00 UTC|newest]

Thread overview: 120+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-06-12  0:00 Ada and Java. different behaviour. casting long to int problem nabbasi
1999-06-12  0:00 ` Tucker Taft
1999-06-12  0:00   ` PPAATT
1999-06-12  0:00   ` Keith Thompson
1999-06-12  0:00     ` kirck
1999-06-13  0:00       ` Robert Dewar
1999-06-12  0:00         ` Fred
1999-06-14  0:00           ` Mark Hood
1999-06-15  0:00             ` mike
1999-06-15  0:00               ` Marin David Condic
1999-06-15  0:00                 ` Mike Silva
1999-06-15  0:00                   ` rich
1999-06-15  0:00                     ` Marin David Condic
1999-06-15  0:00                       ` D'Arcy Smith
1999-06-15  0:00                         ` Keith Thompson [this message]
1999-06-16  0:00                           ` bill
1999-06-16  0:00                             ` George W. Bayles
1999-06-16  0:00                               ` Fraser Wilson
1999-06-17  0:00                               ` Chris Dollin
1999-06-17  0:00                               ` Aidan Skinner
1999-06-17  0:00                                 ` David Botton
1999-06-18  0:00                                   ` Dale Stanbrough
1999-06-18  0:00                                     ` Matthew Heaney
1999-06-18  0:00                                     ` David Botton
1999-06-18  0:00                                       ` Pascal Obry
1999-07-20  0:00                             ` Geoff Bull
1999-06-16  0:00                           ` D'Arcy Smith
1999-06-16  0:00                         ` George W. Bayles
1999-06-16  0:00                           ` D'Arcy Smith
1999-06-16  0:00                           ` Tucker Taft
1999-06-17  0:00                             ` George W. Bayles
1999-06-17  0:00                               ` Tucker Taft
1999-06-17  0:00                                 ` bob
1999-06-16  0:00                           ` D'Arcy Smith
1999-06-17  0:00                           ` Larry Kilgallen
1999-06-16  0:00                         ` Mike Silva
1999-06-16  0:00                           ` D'Arcy Smith
1999-06-16  0:00                             ` kirk
1999-06-16  0:00                               ` D'Arcy Smith
1999-06-17  0:00                                 ` Markus Kuhn
1999-06-17  0:00                                   ` D'Arcy Smith
1999-06-17  0:00                                   ` john
1999-06-17  0:00                                     ` Ed Falis
1999-06-18  0:00                                     ` Aidan Skinner
1999-06-16  0:00                               ` Hyman Rosen
1999-06-17  0:00                                 ` Robert I. Eachus
1999-06-17  0:00                                   ` Hyman Rosen
1999-06-17  0:00                                     ` Marin David Condic
1999-06-17  0:00                                     ` bob
1999-06-18  0:00                                       ` Hyman Rosen
1999-06-18  0:00                                         ` mike
1999-06-18  0:00                                           ` Hyman Rosen
1999-06-19  0:00                                             ` Samuel Mize
1999-06-21  0:00                                               ` Marin David Condic
1999-06-19  0:00                                             ` Dale Stanbrough
1999-06-21  0:00                                               ` Marin David Condic
1999-06-21  0:00                                             ` Mike Silva
1999-06-17  0:00                                 ` Markus Kuhn
1999-06-17  0:00                                 ` Jean-Pierre Rosen
1999-06-17  0:00                                   ` Marin David Condic
1999-06-17  0:00                                     ` Samuel Mize
1999-06-17  0:00                                       ` Marin David Condic
1999-06-22  0:00                                         ` Hyman Rosen
1999-06-22  0:00                                           ` Keith Thompson
1999-06-23  0:00                                             ` Marin David Condic
1999-06-24  0:00                                               ` Robert A Duff
1999-06-24  0:00                                                 ` Marin David Condic
1999-06-23  0:00                                           ` Marin David Condic
1999-06-18  0:00                                       ` Aidan Skinner
1999-06-20  0:00                                 ` Sera Hirasuna
1999-06-19  0:00                                   ` Kio
1999-06-20  0:00                                   ` Vladimir Olensky
1999-06-21  0:00                                   ` Samuel T. Harris
1999-06-22  0:00                                     ` Robert I. Eachus
1999-06-23  0:00                                       ` Aidan Skinner
1999-06-23  0:00                                       ` Richard D Riehle
1999-06-22  0:00                                     ` Richard D Riehle
1999-06-21  0:00                                   ` Hyman Rosen
1999-06-17  0:00                           ` Jean-Pierre Rosen
1999-06-16  0:00                         ` Marin David Condic
1999-06-22  0:00                       ` Robert Dewar
1999-06-23  0:00                         ` Marin David Condic
1999-06-23  0:00                           ` Vladimir Olensky
1999-06-23  0:00                             ` Roedy Green
1999-06-23  0:00                               ` Marin David Condic
1999-06-23  0:00                                 ` Keith Thompson
1999-06-24  0:00                                   ` Mike Silva
1999-06-24  0:00                                   ` Marin David Condic
1999-06-23  0:00                             ` Marin David Condic
1999-06-15  0:00                     ` tmoran
1999-06-15  0:00                       ` David Botton
1999-06-16  0:00                       ` Samuel Mize
1999-06-16  0:00                       ` Richard D Riehle
1999-06-15  0:00                     ` Samuel Mize
1999-06-16  0:00                 ` Mark Hood
1999-06-17  0:00                   ` Jean-Pierre Rosen
1999-06-17  0:00                 ` Robert I. Eachus
1999-06-17  0:00                   ` Marin David Condic
1999-06-15  0:00               ` D'Arcy Smith
1999-06-16  0:00                 ` George W. Bayles
1999-06-16  0:00                   ` D'Arcy Smith
1999-06-17  0:00                   ` Aidan Skinner
1999-06-17  0:00                   ` Matthew Heaney
1999-06-15  0:00               ` Samuel Mize
1999-06-15  0:00                 ` jerry
1999-06-16  0:00                   ` Richard D Riehle
1999-06-16  0:00                     ` jerry
1999-06-17  0:00             ` Markus Kuhn
1999-06-17  0:00               ` David Botton
1999-06-13  0:00   ` Robert Dewar
1999-06-14  0:00     ` tmoran
1999-06-30  0:00       ` John Merryweather Cooper
1999-07-01  0:00         ` Chad R. Meiners
1999-07-02  0:00           ` Robert Dewar
1999-07-02  0:00             ` John Merryweather Cooper
1999-07-03  0:00               ` Robert Dewar
1999-06-12  0:00 ` nabbasi
1999-06-12  0:00   ` jerry
1999-06-12  0:00     ` Robert Dewar
1999-06-14  0:00       ` Marin David Condic
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox