FloatingPoint64Value.ofDouble constructor

FloatingPoint64Value.ofDouble(
  1. double inDouble
)

Numeric conversion of a FloatingPoint64Value from a host double

Implementation

factory FloatingPoint64Value.ofDouble(double inDouble) {
  final byteData = ByteData(8)..setFloat64(0, inDouble);
  final accum = byteData.buffer
      .asUint8List()
      .map((b) => LogicValue.ofInt(b, 64))
      .reduce((accum, v) => (accum << 8) | v);

  return FloatingPoint64Value(
      sign: accum[-1],
      exponent: accum.slice(exponentWidth + mantissaWidth - 1, mantissaWidth),
      mantissa: accum.slice(mantissaWidth - 1, 0));
}