FloatingPointClassifier constructor
Creates a classifier, optionally canonicalizing explicit-J-bit inputs.
Implementation
FloatingPointClassifier(
FloatingPoint value, {
bool alignExplicitJBit = false,
super.name = 'floating_point_classifier',
super.reserveName,
super.reserveDefinitionName,
String? definitionName,
}) : super(
definitionName: definitionName ??
'FloatingPointClassifier_${_formatIdentity(value)}'
'${value.explicitJBit ? '_J1' : ''}',
) {
_requireSupportedFormat(value, alignExplicitJBit);
value = addTypedInput('value', value);
if (value.explicitJBit) {
value = canonicalizeExplicitJBit(value);
}
final exponentZero = ~value.exponent.or();
final mantissaNonzero = value.mantissa.or();
final isSubnormal = exponentZero & mantissaNonzero;
final isZero = value.isAZero;
final isInfinity = value.isAnInfinity;
final isNaN = value.isNaN;
addOutput('sign') <= value.sign;
addOutput('zero') <= isZero;
addOutput('subnormal') <= isSubnormal;
addOutput('normal') <= ~(isZero | isSubnormal | isInfinity | isNaN);
addOutput('infinity') <= isInfinity;
addOutput('quietNaN') <= value.isQuietNaN;
addOutput('signalingNaN') <= value.isSignalingNaN;
}