quietNaNFrom method
- FloatingPoint source
Quiet and convert the NaN payload and sign from source into this format.
Implementation
FloatingPoint quietNaNFrom(FloatingPoint source) {
if (!supportsSignalingNaNs) {
return _constant(valuePopulator().nan, sign: source.sign);
}
final targetFractionWidth = mantissa.width - (explicitJBit ? 1 : 0);
final sourceFractionWidth =
source.mantissa.width - (source.explicitJBit ? 1 : 0);
final targetPayloadWidth = max(0, targetFractionWidth - 1);
final sourcePayloadWidth = max(0, sourceFractionWidth - 1);
late final Logic quietMantissa;
if (targetFractionWidth == 0) {
quietMantissa = Const(1, width: mantissa.width);
} else if (targetPayloadWidth == 0) {
quietMantissa = [
if (explicitJBit) Const(1),
Const(1),
].swizzle();
} else {
Logic payload;
if (sourcePayloadWidth == 0) {
payload = Const(0, width: targetPayloadWidth);
} else {
payload = source.mantissa.getRange(0, sourcePayloadWidth);
payload = payload.width > targetPayloadWidth
? payload.getRange(0, targetPayloadWidth)
: payload.zeroExtend(targetPayloadWidth);
}
quietMantissa = [
if (explicitJBit) Const(1),
Const(1),
payload,
].swizzle();
}
final quiet = clone(name: 'quietNaN');
quiet.sign <= source.sign;
quiet.exponent <= Const(valuePopulator().nan.exponent);
quiet.mantissa <= quietMantissa;
return quiet;
}