Skip to main content
The / operator in Dart is the arithmetic division operator. It evaluates the quotient of two numeric operands and strictly returns a double-precision floating-point number (double), regardless of whether the operands are integers or floating-point values.

Type Signature

In the Dart core num class, the operator is defined with the following signature:

Mechanical Behavior

  • Strict Return Type: Unlike languages (such as C or Java) where dividing two integers implicitly performs truncating integer division, Dart’s / operator always yields a double. If integer division is required, Dart requires the use of the distinct truncating division operator (~/).
  • Operand Types: The operator accepts any subtype of num (int or double) for both the left and right operands.
  • IEEE 754 Compliance: The evaluation adheres to the IEEE 754 standard for floating-point arithmetic.
  • Division by Zero: The / operator does not throw a runtime exception (such as IntegerDivisionByZeroException) when dividing by zero. Instead, it returns standard IEEE 754 floating-point constants:
    • A positive number divided by 0 evaluates to double.infinity.
    • A negative number divided by 0 evaluates to double.negativeInfinity.
    • 0 divided by 0 evaluates to double.nan (Not-a-Number).

Syntax Visualization

Tired of Poor Dart Skills? Fix That With Deep Grasping!Learn More