comp.lang.ada
 help / color / mirror / Atom feed
* Bit operations in Ada
@ 2008-05-23 21:19 Dennis Hoppe
  2008-05-23 22:08 ` Ludovic Brenta
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Dennis Hoppe @ 2008-05-23 21:19 UTC (permalink / raw)


Hello,

I'm new to Ada and bitwise operations is a new challenge in this realm. 
My objective is to manipulate some bit strings in Ada, especially:

a) addition/subtraction mod 2**n,
b) change bits directly (e.g, via array access)
c) shift operations
d) rotate operations
e) and, xor, not, or

I started with an array of booleans of size 2**n, that provides neat 
access to individual bits by means of an index. Unfortunately, 
addition/subtraction mod 2**n is not supported, but essential for me.

Next, I tried modular types (mod 2**n), but ended up with not having 
direct access to individual bits. My last attempt was to use 
Interfaces.Unsinged_n. It is a solid package that simplifies the usage 
of bitwise operations for me by adding shift and rotate operations. 
Addition modulo n works well, but I have to dispense with direct bit 
access, too.

So, what is coming next? Should I go with Interfaces.Unsinged_n and
provide a suitable function that converts the used type into an array of 
boolean? Maybe, I'm ought to use directly an array of boolean and try to 
convert the array into an Unsigned_n; if required to add two bit-strings.

I'm looking forward for some answers.

Best regards,
   Dennis

Best regards,
   Dennis



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

end of thread, other threads:[~2008-06-02 18:22 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-23 21:19 Bit operations in Ada Dennis Hoppe
2008-05-23 22:08 ` Ludovic Brenta
2008-05-24 15:36   ` Simon Wright
2008-06-02 13:27     ` Bit operations in Ada (endianness) Dennis Hoppe
2008-06-02 14:01       ` (see below)
2008-06-02 18:22         ` Jeffrey R. Carter
2008-06-02 17:38       ` Ludovic Brenta
2008-05-23 22:38 ` Bit operations in Ada Robert A Duff
2008-05-24  0:27   ` Randy Brukardt
2008-05-24  9:40   ` Bit operations in Ada (Thank you) Dennis Hoppe
2008-05-23 23:25 ` Bit operations in Ada Jeffrey R. Carter

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