Bitwise operations: Difference between revisions

Content added Content deleted
(→‎{{header|J}}: Added functions to complete expanded requirements.)
(→‎{{header|Ada}}: Added missing pieces from Bitshift task)
Line 7: Line 7:
The following program performs all required operations and prints the resulting values in base 2 for easy checking of the bit values.
The following program performs all required operations and prints the resulting values in base 2 for easy checking of the bit values.


<ada>
<ada> with Ada.Text_Io; use Ada.Text_Io;
with Ada.Text_Io; use Ada.Text_Io;
with Interfaces; use Interfaces;
procedure Bitwise is
procedure Bitwise is
type Byte is mod 2**8;
subtype Byte is Unsigned_8;
package Byte_Io is new Ada.Text_Io.Modular_Io(Byte);
package Byte_Io is new Ada.Text_Io.Modular_Io(Byte);
A : Byte := 255;
A : Byte := 255;
B : Byte := 170;
B : Byte := 170;
X : Byte := 128;
N : Natural := 1;

begin
begin
Put_Line("A and B = "); Byte_Io.Put(Item => A and B, Base => 2);
Put_Line("A and B = "); Byte_Io.Put(Item => A and B, Base => 2);