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/23 Message-ID: #1/1 X-Deja-AN: 493101756 References: <7jt2c0$vrb@drn.newsguy.com> <7k57vb$1ipf@drn.newsguy.com> <3766650F.705125B7@pwfl.com> <7k64t7$igo$1@its.hooked.net> <7k689a$ci2@drn.newsguy.com> <3766C842.E1EAB60A@pwfl.com> <7kp3f2$m9i$1@nnrp1.deja.com> <3770F79C.42132886@pwfl.com> <930160826.778.37@news.remarQ.com> <37873d89.955250958@news.bctel.ca> <3771417A.1541648A@pwfl.com> X-Complaints-To: usenet@nusku.cts.com X-Trace: nusku.cts.com 930173488 1279 198.68.168.21 (23 Jun 1999 21:31:28 GMT) Organization: CTS Network Services NNTP-Posting-Date: 23 Jun 1999 21:31:28 GMT Newsgroups: comp.lang.ada,comp.lang.java.programmer Date: 1999-06-23T21:31:28+00:00 List-Id: Marin David Condic writes: [...] > If I understand you correctly, the answer is "yes". In Ada, it would > look sort of like this: > > X : Integer := Integer'Last ; -- Contains max value for type integer. > > ... > > X := X + 1 ; -- No overflow - X contains Integer'Last Out of curiosity, would it generally be more useful for saturation to be "sticky", like IEEE infinity? For example, with non-sticky saturation, you might get something like this: X : Integer := Integer'Last; ... X := X * 10; -- saturation, X = Integer'Last X := X / 10; -- X = Integer'Last / 10 On the other hand, an infinite value in IEEE floating point is not just a large number; infinity / 10 = infinity. I suspect the answer depends on the application, and on what kind of further calculations you want to do on saturated results. Making saturation sticky would require reserving certain bit patterns in an integer type, which would cause some run-time overhead on all operations on that type. It would also make conversions between a saturating type and an equivalent non-saturating type a little tricky. -- 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.