comp.lang.ada
 help / color / mirror / Atom feed
* Constraint error overflow
@ 2021-04-27 14:04 Richard Iswara
  2021-04-27 15:00 ` Dmitry A. Kazakov
  0 siblings, 1 reply; 9+ messages in thread
From: Richard Iswara @ 2021-04-27 14:04 UTC (permalink / raw)


Ada beginner here. I was trying to multiply the first 100 integer and GNAT throw me a constraint error, overflow. I check the error was on integer 13. So what did I do wrong here?
Gnat CE 2020, Windows 10 Pro 64bit.
Here is the relevant program:

with Ada.Text_IO;
with Ada.Integer_Text_IO;

procedure Simple is
   sum : Natural := 0;
   mul : Natural := 1;

begin
   Ada.Text_IO.Put ( "Sum of first 100 integer is :" );
   Summing:
   for I in 1 .. 100 loop
      sum := sum + I;
   end loop Summing;
   Ada.Integer_Text_IO.Put ( sum );
   Ada.Text_IO.New_Line;

   Ada.Text_IO.Put ( "Multiple of the first 100 integer is :" );
   Ada.Text_IO.New_Line;
   Multiplying:
   for J in 1 .. 100 loop
      Ada.Integer_Text_IO.Put (J);
      Ada.Text_IO.New_Line;
      mul := mul * J;
   end loop Multiplying;
   Ada.Integer_Text_IO.Put ( mul );
   Ada.Text_IO.New_Line;
end Simple;


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

end of thread, other threads:[~2021-04-28  7:03 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-27 14:04 Constraint error overflow Richard Iswara
2021-04-27 15:00 ` Dmitry A. Kazakov
2021-04-27 15:32   ` Richard Iswara
2021-04-27 15:38     ` Mark Lorenzen
2021-04-27 15:44     ` Shark8
2021-04-27 15:52     ` Jeffrey R. Carter
2021-04-27 15:59     ` Dmitry A. Kazakov
2021-04-28  7:03       ` Richard Iswara
2021-04-27 16:31     ` Simon Wright

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