comp.lang.ada
 help / color / mirror / Atom feed
From: stt@henning.camb.inmet.com (Tucker Taft)
Subject: Re: one's complement operator in Ada
Date: 1996/07/26
Date: 1996-07-26T00:00:00+00:00	[thread overview]
Message-ID: <Dv5yoH.Gz9.0.-s@inmet.camb.inmet.com> (raw)
In-Reply-To: 31F8DE73.41C6@afit.af.mil


Ding-yuan Sheu (dsheu@afit.af.mil) wrote:


: 	I am working on a project to convert a C++ program into Ada95.
: I try to find a easy way to achieve the effect of '~' (one's complement
: operator) in C++. I wonder if there is a good way to obtain the same
: result in Ada without programming it as a procedure or function.

The "not" operator on modular integer types (presuming the
modulus is a power of 2) is equivalent to one's complement.

: For example, in C++:

: 	ulong  mask;
: 		:
: 		:

: 	ulong j:= ~mask;

: How can I convert this partical code into Ada in a "easy" way?

    type Unsigned_Long is mod 2**32;

        ...

    Mask : Unsigned_Long;

        ...

    J : Unsigned_Long := not Mask;

: I'll appreciate any help. Thanks in advance.

I hope the above helps.  In general, the bit-wise operators ~, &, |, ^
in C/C++ map directly to "not", "and", "or", and "xor" in Ada 95,
and are defined for boolean, array-of-boolean, and modular.

: 		Steven ( dsheu@afit.af.mil )

-Tucker Taft   stt@inmet.com   http://www.inmet.com/~stt/
Intermetrics, Inc.  Cambridge, MA  USA




  reply	other threads:[~1996-07-26  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-07-26  0:00 one's complement operator in Ada Ding-yuan Sheu
1996-07-26  0:00 ` Tucker Taft [this message]
1996-07-26  0:00 ` Laurent Guerby
replies disabled

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