Bitwise operations: Difference between revisions
→{{header|Kotlin}}: uses pure kotlin; no java
(Add Ecstasy example) |
(→{{header|Kotlin}}: uses pure kotlin; no java) |
||
Line 3,689:
</pre>
=={{header|Kotlin}}==
<syntaxhighlight lang="
fun main() {
▲ // inferred type of x and y is Int i.e. 32 bit signed integers
val x = 10
val y = 2
println("x
println("y
println("NOT x
println("x AND y = ${x and y}")
println("x OR
println("x XOR y = ${x xor y}")
// All operations below actually return (x OP (y % 32)) so that a value is never completely shifted out
println("x SHL y = ${x shl y}")
println("x ASR y = ${x shr y}")
println("x LSR y = ${x ushr y}")
println("x ROL y = ${x
println("x ROR y = ${x
}</syntaxhighlight>
{{out}}
<pre>
x
y
NOT x
x AND y = 2
x OR
x XOR y = 8
x SHL y = 40
Line 3,725 ⟶ 3,723:
x ROR y = -2147483646
</pre>
=={{header|LFE}}==
|