ofDouble method
- double inDouble, {
- FloatingPointRoundingMode roundingMode = FloatingPointRoundingMode.roundNearestEven,
override
Convert from double using its native binary representation
Implementation
@override
FloatingPoint32Value ofDouble(double inDouble,
{FloatingPointRoundingMode roundingMode =
FloatingPointRoundingMode.roundNearestEven}) {
if (roundingMode != FloatingPointRoundingMode.roundNearestEven) {
return super.ofDouble(inDouble, roundingMode: roundingMode);
}
final byteData = ByteData(4)..setFloat32(0, inDouble);
final accum = byteData.buffer
.asUint8List()
.map((b) => LogicValue.ofInt(b, 32))
.reduce((accum, v) => (accum << 8) | v);
return populate(
sign: accum[-1],
exponent: accum.slice(exponentWidth + mantissaWidth - 1, mantissaWidth),
mantissa: accum.slice(mantissaWidth - 1, 0));
}