toScaledBigInt method
Returns this exact finite value as significand * 2^exponent.
Throws for NaN and infinity, which have no finite dyadic representation.
Implementation
({BigInt significand, int exponent}) toScaledBigInt() {
if (isNaN || isAnInfinity) {
throw RohdHclException(
'NaN and infinity have no finite scaled-integer representation.');
}
if (subNormalAsZero && isSubnormal()) {
return (significand: BigInt.zero, exponent: 0);
}
final fractionWidth = mantissaWidth - (explicitJBit ? 1 : 0);
final normal = !exponent.isZero;
var significand = mantissa.toBigInt() |
(normal && !explicitJBit ? BigInt.one << fractionWidth : BigInt.zero);
if (sign.toBool()) {
significand = -significand;
}
final unbiasedExponent = normal ? exponent.toInt() - bias : minExponent;
return (
significand: significand,
exponent: unbiasedExponent - fractionWidth
);
}