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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,b2923d60cb81694b X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news.germany.com!news.teledata-fn.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail Newsgroups: comp.lang.ada Subject: Re: Unsigned Integer Restraint Errors From: Georg Bauhaus In-Reply-To: <1173712032.183064.264340@8g2000cwh.googlegroups.com> References: <1173712032.183064.264340@8g2000cwh.googlegroups.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1173716824.8455.17.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.6.1 Date: Mon, 12 Mar 2007 17:27:04 +0100 Organization: Arcor NNTP-Posting-Date: 12 Mar 2007 17:23:39 CET NNTP-Posting-Host: 02fcbb63.newsspool2.arcor-online.net X-Trace: DXC=m3l_NOKOSBeUoRk[hk2WalA9EHlD;3Ycb4Fo<]lROoRa8kF On Mon, 2007-03-12 at 08:07 -0700, frikk wrote: > Hello Everyone! > > I'm having a trivial difficulty with Ada. I am working with a 64 bit > unsigned integer, and of course I would like to know if the input to > this unsigned integer is out of range. I am having two issues. The > first is that I cannot get ada to raise a constraint error unless I > make a subtype and state the range of being a finite number (but only > in some circumstances, I'll explain in a second). > > procedure Prime_Bits is > -- Declare a 64 bit unsigned integer > type UNSIGNED_LONG_INT is mod 2**64; > > test := -5; This first question is probably answered by LRM 3.4.5, 19. For a modular type, if the result of the execution of a predefined operator is outside the base range of the type, the result is reduced modulo the modulus of the type to a value that is within the base range of the type. HTH