Bitwise operations: Difference between revisions
m
→{{header|Ecstasy}}
(add RPL) |
|||
Line 2,927:
=={{header|Ecstasy}}==
<syntaxhighlight lang="java">
module BitwiseOps {
@Inject Console console;
void run() {
for ((Int64 n1, Int64 n2) : [0=7, 1=5, 42=2, 0x123456789ABCDEF=0xFF]) { // <- test data▼
▲ for ((Int64 n1, Int64 n2) : [0=7, 1=5, 42=2, 0x123456789ABCDEF=0xFF]) // <- test data
▲ static String hex(Int64 n) // <- this is a locally scoped helper function
// formats the integer as a hex string, but drops the leading '0' bytes
return n.toByteArray() [(n.leadingZeroCount / 8).minOf(7) ..< 8].toString();
console.print($|For values {n1} ({hex(n1)}) and {n2} ({hex(n2)}):
Line 2,959 ⟶ 2,955:
|
);
}
}
}
</syntaxhighlight>
|