ofDouble method

FxvType ofDouble(
  1. double val, {
  2. FloatingPointRoundingMode roundingMode = FloatingPointRoundingMode.truncate,
})

Constructs a FixedPointValue from a Dart double.

roundingMode defaults to truncation to preserve the historical behavior of this method.

Implementation

FxvType ofDouble(double val,
    {FloatingPointRoundingMode roundingMode =
        FloatingPointRoundingMode.truncate}) {
  if (!val.isFinite) {
    throw RohdHclException(
        'NaN and infinity cannot be converted to FixedPointValue.');
  }
  final fpv = FloatingPoint64Value.populator().ofDouble(val);
  return ofFloatingPointValue(fpv, roundingMode: roundingMode);
}