comp.lang.ada
 help / color / mirror / Atom feed
* Re: one's complement operator in Ada
  1996-07-26  0:00 one's complement operator in Ada Ding-yuan Sheu
@ 1996-07-26  0:00 ` Laurent Guerby
  1996-07-26  0:00 ` Tucker Taft
  1 sibling, 0 replies; 3+ messages in thread
From: Laurent Guerby @ 1996-07-26  0:00 UTC (permalink / raw)



Steven> For example, in C++:

Steven> 	ulong mask;

Steven> 	ulong j:= ~mask;

   For example, in Ada 95:

   type U_Long is mod 2 ** 32;
   --  or use Interfaces.Unsigned_32

   Mask : U_Long;

   J : U_Long := not Mask;

   Question, how do you do easily a mask rotation in C? In Ada 95,
you just use Interfaces.Rotate_Left (or Right).

-- 
Laurent Guerby <guerby@gnat.com>, Team Ada.
   "Use the Source, Luke. The Source will be with you, always (GPL)."




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: one's complement operator in Ada
  1996-07-26  0:00 one's complement operator in Ada Ding-yuan Sheu
  1996-07-26  0:00 ` Laurent Guerby
@ 1996-07-26  0:00 ` Tucker Taft
  1 sibling, 0 replies; 3+ messages in thread
From: Tucker Taft @ 1996-07-26  0:00 UTC (permalink / raw)



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




^ permalink raw reply	[flat|nested] 3+ messages in thread

* one's complement operator in Ada
@ 1996-07-26  0:00 Ding-yuan Sheu
  1996-07-26  0:00 ` Laurent Guerby
  1996-07-26  0:00 ` Tucker Taft
  0 siblings, 2 replies; 3+ messages in thread
From: Ding-yuan Sheu @ 1996-07-26  0:00 UTC (permalink / raw)
  Cc: dsheu, mkanko, lawlis


Hello all,

	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.

For example, in C++:

	ulong  mask;
		:
		:

	ulong j:= ~mask;

How can I convert this partical code into Ada in a "easy" way?
I'll appreciate any help. Thanks in advance.


		Steven ( dsheu@afit.af.mil )




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1996-07-26  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-07-26  0:00 one's complement operator in Ada Ding-yuan Sheu
1996-07-26  0:00 ` Laurent Guerby
1996-07-26  0:00 ` Tucker Taft

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