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: 109fba,98ad5b2a2cd88a53 X-Google-Attributes: gid109fba,public X-Google-Thread: 103376,98ad5b2a2cd88a53 X-Google-Attributes: gid103376,public From: Gautier.DeMontmollin@maths.unine.ch Subject: Re: Ada or C++ acting 'correctly' here? Date: 1999/03/02 Message-ID: #1/1 X-Deja-AN: 450300722 References: <7b8c7u$sj1@drn.newsguy.com> <7bg0pc$5a4$1@ffx2nh3.news.uu.net> Organization: University of Neuchatel, Switzerland Newsgroups: comp.lang.ada,comp.lang.c++ Date: 1999-03-02T00:00:00+00:00 List-Id: "Willliam V" writes: > 500000000*7 is a negative quantity. Wow! A new axiom in mathematics!! > C++ prints out > what you ask it to do. Absolutely - it does the modulo 2^32 and returns a signed value. > try unsigned long l = 500000000*7; > cout << l; > or even > cout << ((unsigned long )500000000)*7); BTW: shouldn't the output be *unsigned* (modulo 2^32) ?! > If Linux 'd make the unsigned long to be 64 bit, you Ada would > have compiled fine. The standard integer would be 64 bit - but the "problem" would come again with 2^62 * 7... > So the Ada compiler you are using is > relying very heavily on the underlying C machinery. Not that much, since the Ada compiler *did* detect the overflow - as it should ! > Don't be > too fast to blame C or C++ It was a question about languages behaviours... Did someone blame C/C++ ? -- Gautier -------- Homepage: http://www.unine.ch/math/Personnel/Assistants/Gautier/Montmollin.html Software: http://www.unine.ch/math/Personnel/Assistants/Gautier/Gaut_FTP.htm