double in Dart is a 64-bit (double-precision) floating-point number, as specified by the IEEE 754 standard. It is a concrete implementation of the abstract num class and represents fractional values or integers too large to be represented by the 64-bit signed int type.
Underlying Representation
Thedouble type conforms to the binary64 format. The 64 bits are allocated as follows:
- 1 bit: Sign
- 11 bits: Exponent
- 52 bits: Significand (Mantissa)
Syntax and Literals
Double literals are defined by including a decimal point or by using an exponent. Since Dart 2.1, integer literals are automatically converted todouble when used in a context where a double is expected.
Special Values
Thedouble class supports specific constants defined by the IEEE 754 standard to handle arithmetic exceptions and limits.
- NaN (Not a Number): Result of undefined operations (e.g.,
0.0 / 0.0). - Infinity: Result of overflow or division by zero (e.g.,
1.0 / 0.0). - Negative Infinity: Result of negative overflow or division by negative zero (e.g.,
-1.0 / 0.0).
Arithmetic and Division
While thenum class defines basic operators (+, -, *), the division operator / in Dart always results in a double, even if both operands are integers.
Equality and Precision
Due to the binary approximation of decimal fractions, floating-point arithmetic may yield representation errors. Equality checks should account for precision loss. NaN Equality: According to IEEE 754,NaN is not equal to any value, including itself.
Platform Implementation
- Dart Native (VM/AOT): Maps directly to the hardware’s 64-bit floating-point processor instructions.
- Dart Web: Compiles to JavaScript
Number. Since JavaScript numbers are also IEEE 754 doubles, the behavior is generally consistent, though bitwise operations may force truncation to 32-bit integers.
Master Dart with Deep Grasping Methodology!Learn More





