const Real &y, Rounding rounding) const {
ValueWithRealFlags<Real> result;
if (IsNotANumber() || y.IsNotANumber()) {
- result.value = NaN(); // NaN + x -> NaN
+ result.value = NotANumber(); // NaN + x -> NaN
if (IsSignalingNaN() || y.IsSignalingNaN()) {
result.flags.set(RealFlag::InvalidArgument);
}
if (isNegative == yIsNegative) {
result.value = *this; // +/-Inf + +/-Inf -> +/-Inf
} else {
- result.value = NaN(); // +/-Inf + -/+Inf -> NaN
+ result.value = NotANumber(); // +/-Inf + -/+Inf -> NaN
result.flags.set(RealFlag::InvalidArgument);
}
} else {
const Real &y, Rounding rounding) const {
ValueWithRealFlags<Real> result;
if (IsNotANumber() || y.IsNotANumber()) {
- result.value = NaN(); // NaN * x -> NaN
+ result.value = NotANumber(); // NaN * x -> NaN
if (IsSignalingNaN() || y.IsSignalingNaN()) {
result.flags.set(RealFlag::InvalidArgument);
}
bool isNegative{IsNegative() != y.IsNegative()};
if (IsInfinite() || y.IsInfinite()) {
if (IsZero() || y.IsZero()) {
- result.value = NaN(); // 0 * Inf -> NaN
+ result.value = NotANumber(); // 0 * Inf -> NaN
result.flags.set(RealFlag::InvalidArgument);
} else {
result.value = Infinity(isNegative);
const Real &y, Rounding rounding) const {
ValueWithRealFlags<Real> result;
if (IsNotANumber() || y.IsNotANumber()) {
- result.value = NaN(); // NaN / x -> NaN, x / NaN -> NaN
+ result.value = NotANumber(); // NaN / x -> NaN, x / NaN -> NaN
if (IsSignalingNaN() || y.IsSignalingNaN()) {
result.flags.set(RealFlag::InvalidArgument);
}
bool isNegative{IsNegative() != y.IsNegative()};
if (IsInfinite()) {
if (y.IsInfinite()) {
- result.value = NaN(); // Inf/Inf -> NaN
+ result.value = NotANumber(); // Inf/Inf -> NaN
result.flags.set(RealFlag::InvalidArgument);
} else { // Inf/x -> Inf, Inf/0 -> Inf
result.value = Infinity(isNegative);
}
} else if (y.IsZero()) {
if (IsZero()) { // 0/0 -> NaN
- result.value = NaN();
+ result.value = NotANumber();
result.flags.set(RealFlag::InvalidArgument);
} else { // x/0 -> Inf, Inf/0 -> Inf
result.value = Infinity(isNegative);
return *this;
}
- // TODO: Configurable NaN representations
- static constexpr Real NaN() {
+ // TODO: Configurable NotANumber representations
+ static constexpr Real NotANumber() {
return {Word{maxExponent}
.SHIFTL(significandBits)
.IBSET(significandBits - 1)
}
// Normalizes and marshals the fields of a floating-point number in place.
- // The value is not a NaN, and a zero fraction means a zero value (i.e.,
+ // The value is a number, and a zero fraction means a zero value (i.e.,
// a maximal exponent and zero fraction doesn't signify infinity, although
// this member function will detect overflow and encode infinities).
RealFlags Normalize(bool negative, std::uint64_t exponent,