From: stt@ada-uts
Subject: Re: unsigned integers in Ada
Date: 26 Apr 88 14:32:00 GMT [thread overview]
Message-ID: <57900067@ada-uts> (raw)
In-Reply-To: 25160@clyde.ATT.COM
Ada requires that all predefined integer types be
symmetric about zero, excepting an extra negative value
(LRM 3.5.4:7), and that all integer types be
derived directly or indirectly from one of these.
However, it would be permissible to define a LONG_INTEGER
which is signed 64 bits, and then define a subtype
of that which is unsigned 32 bits, and implement it
using unsigned 32 bit representation in memory
(though the arithmetic would still have to allow
64-bit intermediate results without NUMERIC_ERROR).
Representation clauses are only allowed for "first named subtypes"
(defined in LRM 13.1:3). The first named subtype is the
subtype identified in a "type definition." The type
is generally anonymous and unconstrained; the identifier specified designates
a subtype. For example
type My_Int is range 0..15;
This is formally equivalent to (see LRM 3.5.4:5,6):
type <anon> is new <predefined-int-type>;
subtype My_Int is <anon> range 0..15;
"My_Int" is therefore the "first named subtype."
Allowing unsigned types in general has been proposed as
a possible addition for the next revision of Ada, but
beware that it would imply NUMERIC_ERROR if the arithmetic
result goes negative, rather than just wrapping around, as
most "C" programmers expect. Furthermore, there would
have to be a rule for deciding which predefined
type is selected for any given integer type definition with
a non-negative range (the signed one or the unsigned one), since
this would determine the legality of negative intermediate
arithmetic results.
Tucker Taft
Intermetrics, Inc.
Cambridge, MA 02138
next prev parent reply other threads:[~1988-04-26 14:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1988-04-20 23:56 unsigned integers in Ada rds
1988-04-26 14:32 ` stt [this message]
-- strict thread matches above, loose matches on Subject: below --
1988-04-27 7:30 Gary Morris @flash
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox