comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@cs.nyu.edu (Robert Dewar)
Subject: Re: Ada83 or DEC Ada: Feature or bug?
Date: 26 Sep 1994 08:54:44 -0400
Date: 1994-09-26T08:54:44-04:00	[thread overview]
Message-ID: <366gak$i75@gnat.cs.nyu.edu> (raw)
In-Reply-To: 360ecv$kq1@hacker.demon.co.uk

In Ada 83, you declare an unsigned value like this:

   type x is range 0 .. 2**32 - 1;

whether your compiler accepts this or not is up to the implementation (trying
to use this on many compilers won't work, but that's not a feature of Ada 83,
merely a (nasty) shortcoming of the implementation).

Note that you won't get wrap around arithmetic with this type, if you want
wrap around arithmetic, then you have to program it, or also check with
your implementor to see if they provide support for unsigned types (both
Dec and Alsys provide some support in separate packages -- other vendors
may too).

If your compiler rejects the above declaration, and if your vendor does not
provide any support for unsigned arithmetic in separate packages you are
out of luck. This is the same situation as the guy who wanted 64-bit signe
arithmetic maybe being out of luck if his compiler did not support it.

Trying to use 32-bit signed for 32-bit unsigned is very unlikely to be
satisfactory. Suppressing checks may work, but many compilers don't do
all possible suppression (it's not required), and you are then writing
erroneous programs which may or may not work.

Note that Ada 94 has mcuh better support for unsigned. Any reasonable
Ada 84 compiler will provide support for 32-bit unsigned arithmetic in
a convenient form:

   type unsigned is mod 2 ** 32;


as you might guess from this declaration, the arithmetic is the normal
wrap around (2's complement representation) unsigned arithmetic.




  parent reply	other threads:[~1994-09-26 12:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-09-24  5:45 Ada83 or DEC Ada: Feature or bug? Stephen M. Youndt
1994-09-25 12:32 ` Tucker Taft
1994-09-26 12:54 ` Robert Dewar [this message]
1994-09-26 23:38 ` Wayne Magor
1994-09-27 12:35   ` Bevin R. Brett
1994-10-05  7:59   ` Mike Ellis.......(310) 334-1652
replies disabled

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