toDouble method

double toDouble()

Returns this Rat as a double.

This is a lossy conversion.

Implementation

double toDouble() {
  final length = min(n.bitLength, d.bitLength);
  if (length > 65) {
    final shift = length - 65;
    return (n >> shift).toDouble() / (d >> shift).toDouble();
  }
  return n.toDouble() / d.toDouble();
}