comp.lang.ada
 help / color / mirror / Atom feed
From: Richard Iswara <haujekchifan@gmail.com>
Subject: Constraint error overflow
Date: Tue, 27 Apr 2021 07:04:03 -0700 (PDT)	[thread overview]
Message-ID: <e3861b0f-d8aa-4400-8842-8b16765991f0n@googlegroups.com> (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;


             reply	other threads:[~2021-04-27 14:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-27 14:04 Richard Iswara [this message]
2021-04-27 15:00 ` Constraint error overflow 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
replies disabled

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