comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <jrcarter@acm.org>
Subject: Re: Exceptions in GNAT
Date: Sun, 02 Jun 2002 20:37:10 GMT
Date: 2002-06-02T20:37:10+00:00	[thread overview]
Message-ID: <3CFA8223.DC131896@acm.org> (raw)
In-Reply-To: 3CF9FB01.2070101@yahoo.com

David Rasmussen wrote:
> 
> I am learning Ada, and in one exercise I am told to find out how large
> and integer I can use on my system, before it overflows. The exercise
> just tells me to add two larger and larger numbers and see when an
> exception occurs. I have just compiled my program with gnatmake with no
> options, and I am using gcc 3.1 . When the numbers get large enough, the
> result is just a negative number because of wrap-around. Shouldn't I get
> an exception, unless I turn it off? How do I compile for with most
> checks for debug builds, and how do I compile with everything turned off
> for performance intensive release builds?

By now you've learned that overflow checking is off in GNAT by default,
and how to turn it on.

But your program won't tell you how large an integer you can use on your
system. That information is given by the constant System.Max_Int. Your
program will tell you the largest value of type Integer you can use on
your system, but that can be determined faster from Integer'Last.

The point is that the range of type Integer need not be as large as the
range of the largest possible integer type, System.Min_Int ..
System.Max_Int. For every version of GNAT that I've used, type Integer
is 32 bits, but the largest possible integer type is 64 bits.

-- 
Jeff Carter
"Son of a window-dresser."
Monty Python & the Holy Grail



      parent reply	other threads:[~2002-06-02 20:37 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-06-02 11:01 Exceptions in GNAT David Rasmussen
2002-06-02 11:04 ` David Rasmussen
2002-06-02 12:36   ` Preben Randhol
2002-06-02 12:39   ` Jeffrey Creem
2002-06-02 12:26 ` David C. Hoos, Sr.
2002-06-02 12:28 ` Preben Randhol
2002-06-02 12:39   ` David Rasmussen
2002-06-02 15:34   ` Simon Wright
2002-06-02 15:02 ` Robert Dewar
2002-06-02 20:37 ` Jeffrey Carter [this message]
replies disabled

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