@@ -199,10 +199,11 @@ class LIBSCRATCHCPP_EXPORT Value : public ValueVariant
199199 /* ! Multiplies the given value with the value. */
200200 inline void multiply (const Value &v)
201201 {
202- if ((static_cast <int >(m_type) < 0 ) || (static_cast <int >(v.m_type ) < 0 )) {
203- if (m_type == Type::Infinity || m_type == Type::NegativeInfinity || v.m_type == Type::Infinity || v.m_type == Type::NegativeInfinity) {
204- bool mode = (m_type == Type::Infinity || v.m_type == Type::Infinity);
205- const Value &value = (m_type == Type::Infinity || m_type == Type::NegativeInfinity) ? v : *this ;
202+ Type t1 = m_type, t2 = v.m_type ;
203+ if ((static_cast <int >(t1) < 0 && t1 != Type::NaN) || (static_cast <int >(t2) < 0 && t2 != Type::NaN)) {
204+ if (t1 == Type::Infinity || t1 == Type::NegativeInfinity || t2 == Type::Infinity || t2 == Type::NegativeInfinity) {
205+ bool mode = (t1 == Type::Infinity || t2 == Type::Infinity);
206+ const Value &value = ((t1 == Type::Infinity && (t2 == Type::Infinity || t2 == Type::NegativeInfinity)) || (t2 != Type::Infinity && t2 != Type::NegativeInfinity)) ? v : *this ;
206207 if (value > 0 )
207208 m_type = mode ? Type::Infinity : Type::NegativeInfinity;
208209 else if (value < 0 )
@@ -458,10 +459,11 @@ class LIBSCRATCHCPP_EXPORT Value : public ValueVariant
458459
459460 friend inline Value operator *(const Value &v1, const Value &v2)
460461 {
461- if ((static_cast <int >(v1.m_type ) < 0 ) || (static_cast <int >(v2.m_type ) < 0 )) {
462- if (v1.m_type == Type::Infinity || v1.m_type == Type::NegativeInfinity || v2.m_type == Type::Infinity || v2.m_type == Type::NegativeInfinity) {
463- bool mode = (v1.m_type == Type::Infinity || v2.m_type == Type::Infinity);
464- const Value &value = (v1.m_type == Type::Infinity || v1.m_type == Type::NegativeInfinity) ? v2 : v1;
462+ Type t1 = v1.m_type , t2 = v2.m_type ;
463+ if ((static_cast <int >(t1) < 0 && t1 != Type::NaN) || (static_cast <int >(t2) < 0 && t2 != Type::NaN)) {
464+ if (t1 == Type::Infinity || t1 == Type::NegativeInfinity || t2 == Type::Infinity || t2 == Type::NegativeInfinity) {
465+ bool mode = (t1 == Type::Infinity || t2 == Type::Infinity);
466+ const Value &value = ((t1 == Type::Infinity && (t2 == Type::Infinity || t2 == Type::NegativeInfinity)) || (t2 != Type::Infinity && t2 != Type::NegativeInfinity)) ? v2 : v1;
465467 if (value > 0 )
466468 return Value (mode ? SpecialValue::Infinity : SpecialValue::NegativeInfinity);
467469 else if (value < 0 )
0 commit comments