divideNum static method

double divideNum(
  1. num a,
  2. num b
)

divide (without loosing precision). 两个数相除(防止精度丢失)

Throws ArgumentError if either operand cannot be parsed as a precise Decimal (e.g. non-finite doubles), or if b is zero.

Precision caveat: see addNum. Operands are parsed from their toString() display value, so already-computed doubles carry their floating-point drift, and the final .toDouble() can lose precision for large magnitudes. Prefer divideDecString / divideDec with string operands when exactness matters.

Implementation

static double divideNum(num a, num b) {
  final result = _divideDecimal(a.toString(), b.toString());
  if (result == null) {
    throw ArgumentError(
      'divideNum: operands must be finite numbers and divisor non-zero '
      '(a=$a, b=$b)',
    );
  }
  return result.toDouble();
}