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:
double operator /(num other);

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

// Integer operands
int a = 10;
int b = 4;
double result1 = a / b; // Evaluates to 2.5

// Perfectly divisible integers still return a double
double result2 = 10 / 2; // Evaluates to 5.0

// Floating-point operands
double c = 5.5;
double d = 2.0;
double result3 = c / d; // Evaluates to 2.75

// Division by zero behavior
double inf = 5 / 0;     // Evaluates to Infinity
double negInf = -5 / 0; // Evaluates to -Infinity
double nan = 0 / 0;     // Evaluates to NaN
Tired of Poor Dart Skills? Fix That With Deep Grasping!Learn More