comp.lang.ada
 help / color / mirror / Atom feed
From: dennison@telepath.com
Subject: Re: how to do bit-wise operation on none modular types?
Date: 1999/03/03
Date: 1999-03-03T00:00:00+00:00	[thread overview]
Message-ID: <7bk1kr$j31$1@nnrp1.dejanews.com> (raw)
In-Reply-To: 7bjjck$25t7@news1.newsguy.com

In article <7bjjck$25t7@news1.newsguy.com>,
  Samuel Mize <smize@imagin.net> wrote:
> Bill,
>
> If your status is a positive number, Tucker's answer is good.  (Of course.)
>
> If not -- for instance, if it's a bitmap of status values and the sign
> bit is used -- you'll have to use unchecked conversion.  Make sure the
> unsigned type and the signed type are the same size, and use an instance
> of Unchecked_Conversion to convert the signed type to the modular type.

If this value comes directly from a "pragma import"ed routine, you have
another option. Just change the type of the parameter to a type that would
work better for you (modular integer, packed array of boolean, whatever).
Just make sure the type is the same size as C's "int". Putting a 'size clause
on the type's declaration will enforce this by causing a compilation error
when it won't fit.

> Some people prefer to convert to a packed array of booleans if they're
> working with a boolean bitmap, as they feel it makes the rest of the
> code clearer.

I'm definitely one of those. I just showed a developer here how to do that
this morning. Being an old Fortran guy, he liked it better than how C had him
do it, because it resembled the "btest" call he used to make in Fortran.

T.E.D.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




      parent reply	other threads:[~1999-03-03  0:00 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-03-03  0:00 how to do bit-wise operation on none modular types? bill
1999-03-03  0:00 ` Tarjei Tj�stheim Jensen
1999-03-03  0:00 ` Tucker Taft
1999-03-03  0:00   ` Samuel Mize
1999-03-03  0:00     ` fraser
1999-03-04  0:00       ` Samuel Mize
1999-03-05  0:00         ` fraser
1999-03-04  0:00       ` dennison
1999-03-03  0:00     ` Tucker Taft
1999-03-04  0:00       ` robert_dewar
1999-03-05  0:00         ` bourguet
1999-03-05  0:00           ` robert_dewar
1999-03-04  0:00       ` Tom Moran
1999-03-04  0:00         ` fraser
1999-03-03  0:00     ` dennison [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