comp.lang.ada
 help / color / mirror / Atom feed
From: mheaney@ni.net (Matthew Heaney)
Subject: Re: GNAT for loop can't count!
Date: 1997/07/28
Date: 1997-07-28T00:00:00+00:00	[thread overview]
Message-ID: <mheaney-ya023680002807970945110001@news.ni.net> (raw)
In-Reply-To: 33DCBE03.27E8@reading.ac.uk


In article <33DCBE03.27E8@reading.ac.uk>, William Paul Berriss
<W.P.Berriss@reading.ac.uk> wrote:


>I use GNAT Ada95 compiler v3.07 on a Sun SPARC 5 runnig Solaris 2.5.

This is a very old version of GNAT; the current public release is 3.09. 
Have you considered upgrading?

Also, there is a discussion list for GNAT specificially, called
<mailto:chat@gnat.com>.  Go to the ACT website at <http://www.gnat.com> to
get info about signing up, and consider posting GNAT-specific queries
there.


>I have  very simple for loop that should count upwards from 118 to 129
>but it counts 118, ..., 126, 127, -128, -127  (i.e. changes to
>Negative after 127)
>
>Here is the loop:
>
>      for P in Pixel(Firstp)..Pixel(Lastp) loop             
>
>        Ada.Integer_Text_IO.Put(Integer(P));
>        Ada.Text_IO.New_line;
>
>      end loop;
>
>Where  Pixel is Integer range 0..255
>and
>Firstp and Lastp at this point are 118 and 129 respectively.
>Both of type Pixel.

What is type Pixal? Is it 

   subtype Pixal is Integer range 0 .. 255;

If so, then why did you declare your loop as you did?  Why the cast to
Pixal type, if Firstp and Lastp are already type Pixal?  Why not

   for P in Pixal range Firstp .. Lastp loop

Also, why did you cast the loop index to type integer, if Pixal is already
a subtype of Integer?  Why not

   Ada.Integer_Text_IO.Put (P);

It would help if you showed the _exact_ declaration of type Pixal.

--------------------------------------------------------------------
Matthew Heaney
Software Development Consultant
<mailto:matthew_heaney@acm.org>
(818) 985-1271




  reply	other threads:[~1997-07-28  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-07-28  0:00 GNAT for loop can't count! William Paul Berriss
1997-07-28  0:00 ` Matthew Heaney [this message]
1997-07-28  0:00 ` Robert Dewar
1997-07-29  0:00 ` Anonymous
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox