diff --git a/uppsrc/Core/Complex.h b/uppsrc/Core/Complex.h index 4d7dd9356..7dfa06c2a 100644 --- a/uppsrc/Core/Complex.h +++ b/uppsrc/Core/Complex.h @@ -11,7 +11,7 @@ struct Complex : std::complex Complex(const Nuller&) : C(DOUBLE_NULL) {} operator Value() const { return RichValue(*this); } - Complex(const Value& v) : C(RichValue::Extract(v)) {} + Complex(const Value& v) : C(IsNumber(v) ? C((double)v) : RichValue::Extract(v)) {} bool operator==(const Complex& c) const { return (const C&)(*this) == (const C&)c; } bool operator!=(const Complex& c) const { return (const C&)(*this) != (const C&)c; } @@ -34,5 +34,9 @@ template<> inline dword ValueTypeNo(const Complex*) { return COMPLEX_V; } inline const Complex& Nvl(const Complex& a, const Complex& b) { return IsNull(a) ? b : a; } +inline bool IsPolyEqual(const Complex& x, const Value& v) { + return IsNumber(v) && x.imag() == 0 && x.real() == (double)v; +} + VALUE_COMPARE(Complex) NTL_MOVEABLE(Complex)