subtractNum static method

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

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

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

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 subtractDecString / subtractDec with string operands when exactness matters.

Implementation

static double subtractNum(num a, num b) {
  final result = _subtractDecimal(a.toString(), b.toString());
  if (result == null) {
    throw ArgumentError(
      'subtractNum: operands must be finite numbers (a=$a, b=$b)',
    );
  }
  return result.toDouble();
}