toNum method

num toNum()

Converts this decimal to an int when exact, otherwise to a double.

Implementation

num toNum() {
  if (scale == 0) {
    final asInt = scaledValue.toInt();
    if (BigInt.from(asInt) == scaledValue) {
      return asInt;
    }
  }
  return toDouble();
}