comp.lang.ada
 help / color / mirror / Atom feed
* Simple loop with a strange output
@ 2013-05-23 13:53 Luca Cappelletti
  2013-05-23 13:55 ` Luca Cappelletti
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Luca Cappelletti @ 2013-05-23 13:53 UTC (permalink / raw)


Hello,

I'm using GNAT 4.6 via Debian 7

I've just compiled this simple code coming from a tutorial where I've just a little bit changed to fit my test:


with Ada.Text_IO, Ada.Integer_Text_IO;
use Ada.Text_IO, Ada.Integer_Text_IO;
procedure Hello is

    procedure Raddoppia(Elemento: in out Integer) is
    begin
    
        Elemento := Elemento * 2;
    
    end Raddoppia;

X : Integer;

begin

    Put_Line("start counting");
    New_Line;

    X := 1; 
    while X < 1009999999 loop
        Put(X);
        New_Line;
        Raddoppia(X);
    end loop;

end Hello;

that produce the expected:

$./hello
Ciao a tutti sto usando Put_Line direttamente con la clausola use

          1
          2
          4
          8
         16
         32
         64
        128
        256
        512
       1024
       2048
       4096
       8192
      16384
      32768
      65536
     131072
     262144
     524288
    1048576
    2097152
    4194304
    8388608
   16777216
   33554432
   67108864
  134217728
  268435456
  536870912


now that strange error:

if you change the code using only the simple "loop - end loop" or change the number into the while from 1009999999 to 1099999999

my output will be an infinite sequence of zero

$./hello
0
0
0
0
...
0
...



do you know what's happening?

thank in advance,

Luca

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-05-24 12:46 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-23 13:53 Simple loop with a strange output Luca Cappelletti
2013-05-23 13:55 ` Luca Cappelletti
2013-05-23 14:37 ` Adam Beneschan
2013-05-23 14:41   ` Adam Beneschan
2013-05-23 16:09     ` Luca Cappelletti
2013-05-23 16:40       ` Simon Wright
2013-05-23 21:34         ` Randy Brukardt
2013-05-24  7:21           ` Simon Wright
2013-05-24 12:46           ` Britt
2013-05-23 20:41 ` Dirk Heinrichs

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