ofFloatingPointValueRounded method

FpvType ofFloatingPointValueRounded(
  1. FloatingPointValue fpv, {
  2. FloatingPointRoundingMode roundingMode = FloatingPointRoundingMode.roundNearestEven,
})

Converts fpv directly to this format with one exact rounding step.

Unlike ofDouble, this method does not pass through the host floating-point format and therefore cannot introduce double rounding.

Implementation

FpvType ofFloatingPointValueRounded(FloatingPointValue fpv,
    {FloatingPointRoundingMode roundingMode =
        FloatingPointRoundingMode.roundNearestEven}) {
  if (fpv.isNaN) {
    return _quietNaNFrom(fpv);
  }
  if (fpv.isAnInfinity) {
    return _infinityOrLargestFinite(
        negative: fpv.sign.toBool(), roundingMode: roundingMode);
  }
  return _quantize(_decodeFinite(fpv),
      negative: fpv.sign.toBool(), roundingMode: roundingMode);
}