isNaN method

bool isNaN()

Return true if the represented floating point number is considered NaN or 'Not a Number' due to overflow

Implementation

bool isNaN() {
  if ((exponent.width == 4) & (mantissa.width == 3)) {
    // FP8 E4M3 does not support infinities
    final cond1 = (1 + exponent.toInt()) == pow(2, exponent.width).toInt();
    final cond2 = (1 + mantissa.toInt()) == pow(2, mantissa.width).toInt();
    return cond1 & cond2;
  } else {
    return exponent.toInt() ==
        computeMaxExponent(exponent.width) + computeBias(exponent.width) + 1;
  }
}