From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,fee8802cc3d8334d X-Google-Attributes: gid103376,public X-Google-Thread: 10a146,fee8802cc3d8334d X-Google-Attributes: gid10a146,public From: Samuel Mize Subject: Re: Ada and Java. different behaviour. casting long to int problem. Date: 1999/06/15 Message-ID: <7k5kef$1ghi@news1.newsguy.com>#1/1 X-Deja-AN: 489857561 References: <7jt2c0$vrb@drn.newsguy.com> <7k57vb$1ipf@drn.newsguy.com> Organization: ImagiNet Communications, Ltd. User-Agent: tin/pre-1.4-981002 ("Phobia") (UNIX) (AIX/3-2) Newsgroups: comp.lang.ada,comp.lang.java.programmer Date: 1999-06-15T00:00:00+00:00 List-Id: In comp.lang.ada mike@world.nospam.com wrote: > In article , Mark says... >> >>I think the point is that the result of an overflow isn't necessarily the >>wrong number. >> > > I wonder if the above will be stand in court when a bank customer complains > to the judge that they deposited $5,000 into their saving account > in top of what allready they had in there, only to be told by the bank > that now they have a negative balance. No, it won't, because anyone who can overflow a bank's accounting software can buy whatever verdict he wants. :-) More seriously, saying it "isn't necessarily" wrong doesn't mean that it's always right. It means you have to know what the numerical model does, and handle that behavior appropriately. The programmer is at fault, because he didn't know (or properly use) the Java numerical model. The bank is liable since he's their programmer. The compiler vendor is not at fault -- the object code exactly matched the program, since it's using the Java numerical model. Nor is the Java model "wrong" -- it just doesn't match the mathematical abstraction of "integer." In fact, Ada doesn't either (I don't recall "constraint error" from ANY math classes). The two models map the mathematical abstraction to the real-world limited representation in different ways. For numerical computation the Ada version is more useful. For traditional, C-oriented system programming, and for some other kinds of algorithms, the Java model is more useful. Models of anything are never true or false, only more or less useful. Best, Sam Mize -- Samuel Mize -- smize@imagin.net (home email) -- Team Ada Fight Spam: see http://www.cauce.org/ \\\ Smert Spamonam