"/" - Arithmetic Division Operation

This section provides some detail rules and a tutorial example on how arithmetic division operation works in VBScript.

Here are some detail rules about the arithmetic operation - division:

• Arithmetic division operation uses the division operator: "/"
• Arithmetic division operation requires that at least one of the operands is a numeric subtype: Byte, Integer, Long, Single or Double.
• If an operand is not a numeric subtype, it will be converted into a numeric subtype.
• The Boolean subtype is considered as a numeric subtype in a division operation. "True" represents a numeric value of -1. "False" represents a numeric value of 0.
• The Empty subtype is considered as a numeric subtype in a division operation. "Empty" represents a numeric value of 0.
• When a String value is used in a division operation, it will be parsed into a Double value. If the parsing process fails, the division operation will raise the "Type mismatch" runtime error.
• The operation will fail, if the second operand is a 0. Dividing by 0 is mathematically impossible.
• The returning value is the result of the first operand divided by the second operand.
• The subtype of the returning value is always Double regardless of the returning value range and subtypes of operands.

Here is a tutorial example showing you how arithmetic division operation rules work:

```<html>
<body>
<!-- division_operation.html
-->
<pre>
<script language="vbscript">
document.writeln("21/7=" & (21/7) & " : " & TypeName(21/7))
document.writeln("3/7=" & (3/7) & " : " & TypeName(3/7))
document.writeln("3/777777=" & (3/777777) & " : " _
& TypeName(3/777777))
document.writeln("3/9.99=" & (3/9.99) & " : " & TypeName(3/9.99))
document.writeln("3/333.333e200=" & (3/333.333e200) & " : " _
& TypeName(3/333.333e200))
document.writeln("3/""7""=" & (3/"7") & " : " & TypeName(3/"7"))
'  document.writeln("3/""7Hello""=" & (3/"7Hello") & " : " _
'     & TypeName(3/"7Hello"))
document.writeln("3/True=" & (3/True) & " : " & TypeName(3/True))
'   document.writeln("3/False=" & (3/False) & " : " _
'      & TypeName(3/False))
document.writeln("False/True=" & (False/True) & " : " _
& TypeName(False/True))
document.writeln("Empty/3=" & (Empty/3) & " : " _
& TypeName(Empty/3))
</script>
</pre>
</body>
</html>
```

Here is the output of this VBScript example script:

```21/7=3 : Double
3/7=0.428571428571429 : Double
3/777777=3.85714671428957E-06 : Double
3/9.99=0.3003003003003 : Double
3/333.333e200=9.000009000009E-203 : Double
3/"7"=0.428571428571429 : Double
3/True=-3 : Double
False/True=0 : Double
Empty/3=0 : Single
```

The output confirms some of arithmetic division operation rules:

• Return values from all tests are Double values regardless of the returning value range and subtypes of operands.
• The statement on (3/False) is commented out, because dividing by 0 is not allowed.
• "Empty/3=0 : Single" is very strange. I don't know why.