From: west@widgit.enet.dec.com (Jim West (Stealth Contractor))
Subject: Re: Question with setting sign bit
Date: 6 Dec 90 13:12:40 GMT [thread overview]
Message-ID: <2106@shodha.enet.dec.com> (raw)
In article <18172@hydra.gatech.EDU>,
ms33@prism.gatech.EDU (Mike Sullivan, a.k.a. Sully) writes...
>
> I have a problem setting the sign-bit in an integer while trying to
> explicitly set particular bits (as opposed to storing a negative
> value.) The problem seems to caused by the strong typing of Ada in
> conjunction with a limitation of the compilor. Ada wants me to use
> unsigned integers. The compilor I use does not have unsigned integers
> because the processor does not support unsigned arithmetic. I have
> words that are coming off of a 1553 bus, and a general-purpose package
> passing the information on to me. I want to see if some bits are set,
> or not set as the case may be. There is different situation where I
>
Have you considered using a bit array ? I've done this many times. I
find it far easier to do bit twiddling this way. An example would look
something like :
array_size : constant := 15
type bit is range 0 .. 1;
for bit'size use 1;
type data_type is array (0 .. array_size) of bit;
pragma pack (data_type);
data : data_type;
You could then use this in conjunction with a for-use-at clause and lay
the array on top of a record, or any other data type for manipulation.
-=> Jim <=-
----------------------------------------------------------------------
Jim West | The Schainker Converse
west@widgit.enet.dec.com | to Hoare's Law :
|
These are my opinions. | Inside every small problem
Digital has no idea | is a larger problem struggling
what I'm saying. | to get out.
----------------------------------------------------------------------
next reply other threads:[~1990-12-06 13:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1990-12-06 13:12 Jim West (Stealth Contractor) [this message]
[not found] <18172@hydra.gatech.EDU>
1990-12-13 12:35 ` Question with setting sign bit Eric Beser
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox