ulp method

FloatingPointValue ulp()

Compute the unit in the last place for the given FloatingPointValue.

Implementation

FloatingPointValue ulp() {
  if (exponent.toInt() > mantissa.width) {
    final newExponent =
        LogicValue.ofInt(exponent.toInt() - mantissa.width, exponent.width);
    return clonePopulator().ofBinaryStrings(
        sign.bitString, newExponent.bitString, '0' * (mantissa.width));
  } else {
    return clonePopulator().ofBinaryStrings(
        sign.bitString, exponent.bitString, '${'0' * (mantissa.width - 1)}1');
  }
}