toDouble method

double toDouble()

Converts a fixed-point value to a Dart double.

Implementation

double toDouble() {
  if (m + n > 52) {
    throw RohdHclException('Fixed-point value is too wide to convert.');
  }
  if (!this.value.isValid) {
    throw RohdHclException('Inputs must be valid.');
  }
  BigInt number;
  if (isNegative()) {
    number = (~(this.value - 1)).toBigInt();
  } else {
    number = this.value.toBigInt();
  }
  final value = number.toDouble() / pow(2, n).toDouble();
  return isNegative() ? -value : value;
}