---
title: "Bitwise operators"
canonical: "https://docs.cuesystem.com/space/CVCHELP/522682850/Bitwise%20operators"
format: markdown
---
> Macro (toc)

---

# <<

The arithmetic left shift operator shifts an Expression1 by the number of bites an Expression2 specifies. 

#### Syntax 

```visualbasic
Result := Expression1 << Expression2
```

#### Example 

```visualbasic
Var a As Long := &H8 
Var b As Long := 2 
Var c As Long 

c := a << b 
// c := &H20
```

# >>

The arithmetic right shift operator shifts an Expression1 by the number of bites an Expression2 specifies. 

#### Syntax 

```visualbasic
Result := Expression1 >> Expression2
```

#### Example 

```visualbasic
Var a As Long := &H8 
Var b As Long := 2 
Var c As Long 

c := a >> b 
// c := &H2
```

# BitAnd

The operator bitwise compares each bit of Expression1 to the corresponding bit of Expression2. If both bits are 1, the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0. 

#### BitAnd 

|  |  |  |
| --- | --- | --- |
| Expression1 bit | Expression2 bit | Result bit |
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |

#### Syntax 

```visualbasic
Result := Expression1 BitAnd Expression2
```

#### Example 

```visualbasic
Var a As Long := &H3 
Var b As Long := &H5 
Var c As Long 

c := a BitAnd b 
// c := &H1
```

# BitOr

The operator bitwise compares each bit of Expression1 to the corresponding bit of Expression2. If both bits are 0, the corresponding result bit is set to 0. Otherwise, the corresponding result bit is set to 1. 

#### BitOr 

|  |  |  |
| --- | --- | --- |
| Expression1 bit | Expression2 bit | Result bit |
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |

#### Syntax 

```visualbasic
Result := Expression1 BitOr Expression2
```

#### Example 

```visualbasic
Var a As Long := &H3 
Var b As Long := &H5 
Var c As Long 

c := a BitOr b 
// c := &H7
```

# BitXor

The operator bitwise xor compares each bit of Expression1 to the corresponding bit of Expression2. If just one bit is 1, the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0. 

#### BitXor 

|  |  |  |
| --- | --- | --- |
| Expression1 bit | Expression2 bit | Result bit |
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |

#### Syntax 

```visualbasic
Result := Expression1 BitXor Expression2
```

#### Example 

```visualbasic
Var a As Long := &H3 
Var b As Long := &H5 
Var c As Long 

c := a BitXor b 
// c := &H6
```