From 99c5bc6351bf7690e5dd4fee3fc2f2aee22491c0 Mon Sep 17 00:00:00 2001 From: cxl Date: Wed, 6 Jul 2011 17:23:28 +0000 Subject: [PATCH] Core: Complex - support for conversion from number values, polyequal support git-svn-id: svn://ultimatepp.org/upp/trunk@3624 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/Complex.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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)