comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@world.std.com (Robert A Duff)
Subject: Re: Rep Clause Vaues??
Date: 1997/01/24
Date: 1997-01-24T00:00:00+00:00	[thread overview]
Message-ID: <E4IrC3.IGG@world.std.com> (raw)
In-Reply-To: 01bc0862$77b689c0$018c71a5@dhoossr.iquest.com


In article <01bc0862$77b689c0$018c71a5@dhoossr.iquest.com>,
David C. Hoos, Sr. <david.c.hoos.sr@ada95.com> wrote:
>-- E.g., for Mechs'Size use Integer'Size.
...
>type Mechs_Bit_Pattern_Type is new Integer range 0 .. 2 ** Mechs'Size -1;
>for Mechs_Bit_Pattern_Type'Size use Mechs'Size;

If Mechs'Size = Integer'Size, then Integer'Last is probably
2**(Mechs'Size-1)-1, so the above will overflow.

I suspect you meant:

    type Mechs_Bit_Pattern_Type is range 0 .. 2 ** Mechs'Size -1;

which will work fine, IF the implementation supports integer types
bigger than Integer.

If you want an unsigned type that is the same size as the biggest
supported signed integer, then you have to use modular types, which is
unfortunate, because you lose overflow checking.  (It's unfortunate if
you *want* overflow checking, that is.)

- Bob




  reply	other threads:[~1997-01-24  0:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-01-22  0:00 Rep Clause Vaues?? Robert B. Love 
1997-01-22  0:00 ` Samuel Tardieu
1997-01-22  0:00 ` David C. Hoos, Sr.
1997-01-24  0:00   ` Robert A Duff [this message]
1997-01-25  0:00 ` Robert Dewar
1997-01-26  0:00   ` Matthew Heaney
1997-01-26  0:00     ` Robert Dewar
replies disabled

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