# 算术运算符 (Visual Basic)

## 算术运算

Dim x As Integer
x = 67 + 34
x = 32 - 12


Dim x As Integer = 65
Dim y As Integer
y = -x


Dim y As Double
y = 45 * 55.23
y = 32 / 23


Dim z As Double
z = 23 ^ 3
' The preceding statement sets z to 12167 (the cube of 23).


Dim k As Integer
k = 23 \ 5
' The preceding statement sets k to 4.


Dim x As Integer = 100
Dim y As Integer = 6
Dim z As Integer
z = x Mod y
' The preceding statement sets z to 4.

Dim a As Double = 100.3
Dim b As Double = 4.13
Dim c As Double
c = a Mod b
' The preceding statement sets c to 1.18.


### 尝试被零除

Double Double 0 NaN (不是数学定义的数字)
Double Double > 0 PositiveInfinity
Double Double < 0 NegativeInfinity

## Bit-Shift操作

• 0 表示算术左移

• 0 表示正数的算术右移

• 0 表示无符号数据类型的算术右移 Byte UShort UInteger (、、、) ULong

• 1 表示负数的算术右移 SByte (、、 或 Short Integer) Long

Dim lResult, rResult As Integer
Dim pattern As Integer = 12
' The low-order bits of pattern are 0000 1100.
lResult = pattern << 3
' A left shift of 3 bits produces a value of 96.
rResult = pattern >> 2
' A right shift of 2 bits produces value of 3.