# / Operator (Visual Basic)

**Visual Studio 2005**

Divides two numbers and returns a floating-point result.

expression1 / expression2

The result is the full quotient of expression1 divided by expression2, including any remainder.

The \ Operator returns the integer quotient, which drops the remainder.

The data type of the result depends on the types of the operands. The following table shows how the data type of the result is determined.

Operand data types | Result data type |
---|---|

Both expressions are integral data types (SByte, Byte, Short, UShort, Integer, UInteger, Long, ULong) | |

Both expressions are of the Decimal data type | |

Both expressions are of the Single Data Type (Visual Basic) | |

Either expression is a floating-point data type (Single Data Type (Visual Basic) or Double Data Type (Visual Basic)) | |

Before division is performed, any integral numeric expressions are widened to **Double**. If you assign the result to an integral data type, Visual Basic attempts to convert the result from **Double** to that type. This can throw an exception if the result does not fit in that type. In particular, see "Attempted Division by Zero" on this Help page.

If expression1 or expression2 evaluates to Nothing, it is treated as zero.

### Attempted Division by Zero

If expression2 evaluates to zero, the **/** operator behaves differently for different operand data types. The following table shows the possible behaviors.

Operand data types | Behavior if expression2 is zero |
---|---|

Floating-point ( | Returns infinity (PositiveInfinity or NegativeInfinity), or NaN (not a number) if expression1 is also zero |

| Throws DivideByZeroException |

Integral (signed or unsigned) | Attempted conversion back to integral type throws OverflowException because integral types cannot accept |

Note |
---|

The |

This example uses the **/** operator to perform floating-point division. The result is the quotient of the two operands.

Dim resultValue As Double resultValue = 10 / 4 resultValue = 10 / 3

The expressions in the preceding example return values of 2.5 and 3.333333. Note that the result is always floating-point (**Double**), even though both operands are integer constants.