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!postnews.google.com!n33g2000cwc.googlegroups.com!not-for-mail From: "Adam Beneschan" Newsgroups: comp.lang.ada Subject: Re: Unsigned Integer Restraint Errors Date: 12 Mar 2007 13:07:41 -0700 Organization: http://groups.google.com Message-ID: <1173730061.258778.118030@n33g2000cwc.googlegroups.com> References: <1173712032.183064.264340@8g2000cwh.googlegroups.com> <1173720219.194301.327140@c51g2000cwc.googlegroups.com> <1173723067.887249.88160@n33g2000cwc.googlegroups.com> <1173729631.777149.209370@p10g2000cwp.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1173730066 5328 127.0.0.1 (12 Mar 2007 20:07:46 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 12 Mar 2007 20:07:46 +0000 (UTC) In-Reply-To: <1173729631.777149.209370@p10g2000cwp.googlegroups.com> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: n33g2000cwc.googlegroups.com; posting-host=66.126.103.122; posting-account=cw1zeQwAAABOY2vF_g6V_9cdsyY_wV9w Xref: g2news1.google.com comp.lang.ada:14493 Date: 2007-03-12T13:07:41-07:00 List-Id: On Mar 12, 1:00 pm, "frikk" wrote: > On Mar 12, 2:11 pm, "frikk" wrote: > > > > > On Mar 12, 1:23 pm, "Adam Beneschan" wrote: > > > > On Mar 12, 8:07 am, "frikk" wrote: > > > > > LASTLY: > > > > Please note that when I change the range value from 0 .. 5 to 0 .. > > > > 2**64-1, or 0 .. UNSIGNED_LONG_INT'Last, there is no constraint error > > > > raised. This is the same behavior as the first example. > > > > I missed this question the first time. > > > [...] > > > > -- Adam > > > Thanks for the answers Adam. What you've said about the '-' makes > > sense. I'll look into this. > > > The deal about how the constraint error being raised is outside the > > scope of the procedure makes sense as well. I'll update my code to > > reflect this. > > > So if I compile with gnato - should this fix my constraint error > > raising? Basically I just need to be able to detect if the input is > > outside the range - without using something like "if x < 0 or x > > > 2**64 then" ... > > > Thank you everyone! > > Blaine > > As it turns out, the example that I've posted works just fine when I > use command line arguments: > > b := UNSIGNED_LONG_INT'VALUE(Argument(2)); > > The constraint is thrown perfectly. I do this inside the procedure, of > course, not in the declarations. > Interesting eh? Not unexpected, though. As I said, something like -5 in an Ada program is not a single number, but rather a unary operator "-" applied to a numeric literal. But in other cases, such as the argument to a 'Value operation or when reading a number from a text file with an instance of Text_IO.Integer_IO, "-" *is* considered part of the number, and does not denote the unary "-" operator. What I said about "-" applies only in Ada source code. -- Adam