From: "Adam Beneschan" <adam@irvine.com>
Subject: Re: Unsigned Integer Restraint Errors
Date: 12 Mar 2007 13:07:41 -0700
Date: 2007-03-12T13:07:41-07:00 [thread overview]
Message-ID: <1173730061.258778.118030@n33g2000cwc.googlegroups.com> (raw)
In-Reply-To: <1173729631.777149.209370@p10g2000cwp.googlegroups.com>
On Mar 12, 1:00 pm, "frikk" <frik...@gmail.com> wrote:
> On Mar 12, 2:11 pm, "frikk" <frik...@gmail.com> wrote:
>
>
>
> > On Mar 12, 1:23 pm, "Adam Beneschan" <a...@irvine.com> wrote:
>
> > > On Mar 12, 8:07 am, "frikk" <frik...@gmail.com> 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
next prev parent reply other threads:[~2007-03-12 20:07 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-12 15:07 Unsigned Integer Restraint Errors frikk
2007-03-12 16:27 ` Georg Bauhaus
2007-03-12 17:17 ` Adam Beneschan
2007-03-12 17:23 ` Adam Beneschan
2007-03-12 18:11 ` frikk
2007-03-12 20:00 ` frikk
2007-03-12 20:07 ` Adam Beneschan [this message]
2007-03-12 18:00 ` Dmitry A. Kazakov
2007-03-12 19:00 ` Martin Krischik
2007-03-12 21:13 ` Dmitry A. Kazakov
2007-03-12 19:13 ` frikk
2007-03-12 19:22 ` Randy Brukardt
2007-03-13 3:13 ` Jeffrey R. Carter
2007-03-13 3:00 ` Randy Brukardt
2007-03-13 12:09 ` frikk
2007-03-13 14:58 ` frikk
2007-03-13 15:31 ` frikk
2007-03-13 15:59 ` Robert A Duff
2007-03-13 16:18 ` Dmitry A. Kazakov
2007-03-13 16:21 ` Jeffrey R. Carter
2007-03-13 16:04 ` Adam Beneschan
2007-03-13 16:41 ` Adam Beneschan
2007-03-13 16:42 ` Adam Beneschan
2007-03-14 14:06 ` frikk
2007-03-13 17:23 ` Dmitry A. Kazakov
2007-03-13 17:31 ` Adam Beneschan
2007-03-14 0:54 ` Jeffrey R. Carter
2007-03-16 13:38 ` frikk
2007-03-13 16:16 ` Jeffrey R. Carter
2007-03-12 21:04 ` Dmitry A. Kazakov
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox