asDouble property Null safety

double asDouble

Interpret this value as a floating point, and convert to a double. There is no corresponding asInt method, because the int interpretation depends on the bit size and the sign mode - cf. IntegerSignMode.toBigInt()

Implementation

double get asDouble {
  final BigInt upper52 = _upper52;
  String mantissa = (upper52 & _mantissaMagnitude).toRadixString(16);
  final int sign = (upper52 >> 40).toInt();
  double m = double.parse(mantissa);
  if (sign != 0) {
    if (sign == 0x9) {
      m = -m;
    } else {
      throw CalculatorError(6, num15: 1);
    }
  }
  return m * pow(10.0, (exponent - 9).toDouble());
}