/) calculates the standard quotient of two numbers. It is a binary operator that accepts operands of type num (covering both int and double) and invariably returns a result of type double.
Syntax
Type Resolution
In Dart, the/ operator does not perform truncating integer division, even if both operands are integers.
| Operand A Type | Operand B Type | Return Type | Example | Result |
|---|---|---|---|---|
int | int | double | 10 / 2 | 5.0 |
double | int | double | 10.0 / 2 | 5.0 |
int | double | double | 10 / 2.5 | 4.0 |
Compile-Time Constants
If the operands are compile-time constants, the result of the division is also treated as a compile-time constant, provided the operation does not result in an error.Special Values (IEEE 754)
The operator adheres to IEEE 754 floating-point arithmetic standards regarding special values:- Infinity: Dividing a non-zero number by zero results in
Infinityor-Infinity. It does not throw an exception. - NaN (Not a Number): Dividing
0by0(or0.0by0.0) results inNaN.
Distinction from Truncating Division
To perform division that returns an integer (truncating the fractional part), Dart provides the~/ operator. The / operator preserves the fractional component.
Master Dart with Deep Grasping Methodology!Learn More





