Anonymous user
Bitwise operations: Difference between revisions
m
Forgot to change a few variable names
(Moved PHP shift code over) |
m (Forgot to change a few variable names) |
||
Line 20:
Put_Line("A xor B = "); Byte_Io.Put(Item => A xor B, Base => 2);
Put_Line("Not A = "); Byte_IO.Put(Item => not A, Base => 2);
Put_Line(Unsigned_8'Image(Shift_Left(
Put_Line(Unsigned_8'Image(Shift_Right(
Put_Line(Unsigned_8'Image(Shift_Right_Arithmetic(
Put_Line(Unsigned_8'Image(Rotate_Left(
Put_Line(Unsigned_8'Image(Rotate_Right(
end bitwise;</ada>
Line 60:
printf("a xor b: %d\n", a ^ b);
printf("not a: %d\n", ~a);
printf("a << n: %d\n",
printf("a >> n: %d\n",
/* convert the signed integer into unsigned, so it will perform logical shift */
unsigned int c = a;
Line 246:
Printf.printf "a xor b: %d\n" (a lxor b);
Printf.printf "not a: %d\n" (lnot a)
Printf.printf "
Printf.printf "
Printf.printf "
=={{header|Perl}}==
Line 268:
=={{header|PHP}}==
{{incorrect|PHP}}
▲echo '$x << $n: ', $x << $n, "\n"; // left shift
▲echo '$x >> $n: ', $x >> $n, "\n"; // arithmetic right shift</php>
=={{header|Python}}==
<python>def bitwise(a, b):
|