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.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.224.174.145 with SMTP id t17mr6458650qaz.4.1369319844402; Thu, 23 May 2013 07:37:24 -0700 (PDT) X-Received: by 10.50.56.6 with SMTP id w6mr203652igp.0.1369319844331; Thu, 23 May 2013 07:37:24 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!mx05.eternal-september.org!feeder.eternal-september.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!usenet-fr.net!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!nx02.iad01.newshosting.com!newshosting.com!69.16.185.11.MISMATCH!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!t14no443702qam.0!news-out.google.com!y6ni51092qax.0!nntp.google.com!ch1no806495qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 23 May 2013 07:37:24 -0700 (PDT) In-Reply-To: <7cd707ce-ebc5-4df1-9ec3-4f99ce87a07d@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ NNTP-Posting-Host: 66.126.103.122 References: <7cd707ce-ebc5-4df1-9ec3-4f99ce87a07d@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <96af9cd4-3368-4866-a38e-2514a0a7a54d@googlegroups.com> Subject: Re: Simple loop with a strange output From: Adam Beneschan Injection-Date: Thu, 23 May 2013 14:37:24 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 1925 Xref: news.eternal-september.org comp.lang.ada:15638 Date: 2013-05-23T07:37:24-07:00 List-Id: On Thursday, May 23, 2013 6:53:19 AM UTC-7, Luca Cappelletti wrote: > do you know what's happening? Overflow. The largest possible value of an "integer" type on this platform is (2**31)= -1. So when X hits 2**30 and then you double it, the actual value, 2**31, = won't fit in an integer. If you use the right flags when compiling (I don'= t remember what they are), this will cause a Constraint_Error to be raised.= But since you didn't use those flags, the result will be whatever the pro= cessor returns, which will be -2**31. Since this is less than 1099999999, = it will loop back and try to double it again; now when you double it the pr= ocessor will return 0, and then you get stuck in an infinite loop. -- Adam