# ビット演算

### F#

```> 0b11 &&& 0b10;;
val it : int = 2
> 0b1010 &&& 0b1101;;
val it : int = 8
> 0b1010 ||| 0b1101;;
val it : int = 15
> 0b1010 ^^^ 0b1101;;
val it : int = 7
> 0b1010 <<< 3;;
val it : int = 80
> 0b1010 <<< 2;;
val it : int = 40
> 0b1010 <<< 1;;
val it : int = 20
> 0b1010 <<< 0;;
val it : int = 10```

Core.Operators モジュール (F#)

### Ruby

```[2] pry(main)> 0b1010 & 0b1101
=> 8
[3] pry(main)> 0b1010 | 0b1101
=> 15
[4] pry(main)> 0b1010 ^ 0b1101
=> 7
[5] pry(main)> 0b1010 << 3
=> 80
[6] pry(main)> 0b1010 << 2
=> 40
[7] pry(main)> 0b1010 << 1
=> 20
[8] pry(main)> 0b1010 << 9
=> 5120
[9] pry(main)> 0b1010 << 0
=> 10```

ビット演算子 - 数値と四則演算 - Ruby入門

### Python

```>>> 0b1010 & 0b1101
8
>>> 0b1010 | 0b1101
15
>>> 0b1010 ^ 0b1101
7
>>> 0b1010 << 3
80
>>> 0b1010 << 2
40
>>> 0b1010 << 1
20```

ビット演算子 - 数値 - Python入門

### Scala

```scala> val num1 = Integer.parseInt( "1101", 2 ) ;
num1: Int = 13

scala> val num1 = Integer.parseInt( "1010", 2 ) ;
num1: Int = 10

scala> val num2 = Integer.parseInt( "1101", 2 ) ;
num2: Int = 13

scala> num1 & num2
res3: Int = 8

scala> num1 | num2
res4: Int = 15

scala> num1 ^ num2
res5: Int = 7

scala> num1 << 3
res6: Int = 80

scala> num1 << 2
res7: Int = 40

scala> num1 << 1
res8: Int = 20```

【1日1Java】2進数、8進数、16進数への変換 : mwSoft blog