toDouble method
Return the value of the floating point number in a Dart double type.
Implementation
double toDouble() {
if (isNaN) {
return double.nan;
}
if (isAnInfinity) {
return sign.isZero ? double.infinity : double.negativeInfinity;
}
var doubleVal = double.nan;
if (value.isValid) {
if (exponent.toInt() == 0) {
if (subNormalAsZero) {
doubleVal = 0.0;
} else {
doubleVal = (sign.toBool() ? -1.0 : 1.0) *
pow(2.0, minExponent) *
mantissa.toBigInt().toDouble() /
pow(2.0, mantissa.width - (explicitJBit ? 1 : 0));
}
} else if (!isNaN) {
doubleVal = (sign.toBool() ? -1.0 : 1.0) *
((explicitJBit ? 0.0 : 1.0) +
mantissa.toBigInt().toDouble() /
pow(2.0, mantissa.width - (explicitJBit ? 1 : 0))) *
pow(2.0, exponent.toInt() - bias);
}
}
return doubleVal;
}