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: Keith Thompson Subject: Re: Ada and Java. different behaviour. casting long to int problem. Date: 1999/06/12 Message-ID: #1/1 X-Deja-AN: 488917395 References: <7jt2c0$vrb@drn.newsguy.com> X-Complaints-To: usenet@nusku.cts.com X-Trace: nusku.cts.com 929229704 9475 198.68.168.21 (12 Jun 1999 23:21:44 GMT) Organization: CTS Network Services NNTP-Posting-Date: 12 Jun 1999 23:21:44 GMT Newsgroups: comp.lang.ada,comp.lang.java.programmer Date: 1999-06-12T23:21:44+00:00 List-Id: stt@houdini.camb.inmet.com (Tucker Taft) writes: [...] > Integer conversion (casting) in Java is truncating. [...] > Java is largely following C/C++ semantics in this area, FWIW, > though C/C++ provide *implicit* truncating conversions, whereas > truncating conversions in Java must be explicit casts. Actually, Java follows *de facto* C/C++ semantics. In C and C++, unsigned integer arithmetic is defined to wrap around, but overflow on signed integer arithmetic produces undefined behavior. Almost all existing implementations provide wraparound on signed overflow, but it's not required by the language definitions. All this is from memory; please correct me (gently) if I'm mistaken. -- Keith Thompson (The_Other_Keith) kst@cts.com San Diego Supercomputer Center <*> One of the great tragedies of ancient history is that Helen of Troy lived before the invention of the champagne bottle.