Bitwise operations: Difference between revisions

m
Line 35:
=={{header|ALGOL 68}}==
main:(
PRIO ROL = 8, ROR = 8; # ROL and ROR are not built in, define and overload them here #
OP ROL = (BITS b, INT rotate) BITS: b SHL rotate OR b SHR ( bits width - rotate );
OP ROR = (BITS b, INT rotate) BITS: b SHR rotate OR b SHL ( bits width - rotate );
OP ROL = (LONG BITS b, INT rotate) LONG BITS: b SHL rotate OR b SHR ( long bits width - rotate );
OP ROR = (LONG BITS b, INT rotate) LONG BITS: b SHR rotate OR b SHL ( long bits width - rotate );
OP ROL = (LONG LONG BITS b, INT rotate) LONG LONG BITS: b SHL rotate OR b SHR ( long long bits width - rotate );
OP ROR = (LONG LONG BITS b, INT rotate) LONG LONG BITS: b SHR rotate OR b SHL ( long long bits width - rotate );
PROC bitwise = (BITS a, BITS b, INT shift)VOID:
(
Line 46 ⟶ 55:
$" long bits width: "gxgl$, long bits width, "The number of CHAR required to display LONG BITS",
$" long long bits width: "gxgl$, long long bits width, "The number of CHAR required to display LONG LONG BITS",
$" bytes shorths: "gxgl$, bytes shorths, "1 plus the number of extra SHORT BYTES types",
$" bytes lengths: "gxgl$, bits lengths, "1 plus the number of extra LONG BYTES types",
$" bytes width: "gxgl$, bytes width, "The number of CHAR required to display BYTES",
$" long bytes width: "gxgl$, long bytes width, "The number of CHAR required to display LONG BYTES"
Line 59 ⟶ 68:
printf(($" not b: "gl$, NOT a));
printf(($" a shl "d": "gl$, shift, a SHL shift));
printf(($" a shr "d": "gl$, shift, a SHR shift));
printf(($" a rol "d": "gl$, shift, a ROL shift));
printf(($" a ror "d": "gl$, shift, a ROR shift))
);
bitwise(BIN 255, BIN 170, 5)
)
Line 72 ⟶ 85:
long bits width: +116 The number of CHAR required to display LONG BITS
long long bits width: +209 The number of CHAR required to display LONG LONG BITS
bytes shorths: +1 1 plus the number of extra SHORT BYTES types
bytes lengths: +3 1 plus the number of extra LONG BYTES types
bytes width: +32 The number of CHAR required to display BYTES
long bytes width: +64 The number of CHAR required to display LONG BYTES
Line 84 ⟶ 97:
a shl 5: FFFFFFFFFFFFFFFFFFFTTTTTTTTFFFFF
a shr 5: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFTTT
a rol 5: FFFFFFFFFFFFFFFFFFFTTTTTTTTFFFFF
a ror 5: TTTTTFFFFFFFFFFFFFFFFFFFFFFFFTTT
 
=={{header|BASIC}}==