Decimal.fromDoubleWithLowerMagnitude constructor

Decimal.fromDoubleWithLowerMagnitude(
  1. double f,
  2. int magnitude
)

Construct an Decimal from an float, with a given power of 10 for the lower magnitude

See the Rust documentation for try_from_f64 for more information.

See the Rust documentation for FloatPrecision for more information.

Throws DecimalLimitError on failure.

Implementation

factory Decimal.fromDoubleWithLowerMagnitude(double f, int magnitude) {
  final result = _icu4x_Decimal_from_double_with_lower_magnitude_mv1(f, magnitude);
  if (!result.isOk) {
    throw DecimalLimitError();
  }
  return Decimal._fromFfi(result.union.ok, []);
}