diff options
author | Mike Buland <mike@xagasoft.com> | 2013-04-23 10:24:18 -0600 |
---|---|---|
committer | Mike Buland <mike@xagasoft.com> | 2013-04-23 10:24:18 -0600 |
commit | e6401f9af190cfbaaab1dc5589546ba5cc2f5293 (patch) | |
tree | f77f3d8d1068971e46a51394a345b780b1ebd6bc /src/number.cpp | |
parent | 3c8dbfe5bb53b8cca319d64a64450e1360a9911d (diff) | |
download | clic-e6401f9af190cfbaaab1dc5589546ba5cc2f5293.tar.gz clic-e6401f9af190cfbaaab1dc5589546ba5cc2f5293.tar.bz2 clic-e6401f9af190cfbaaab1dc5589546ba5cc2f5293.tar.xz clic-e6401f9af190cfbaaab1dc5589546ba5cc2f5293.zip |
Added == operator to compare Numbers & strings
We may be able to go even a step further, but it actually parses the
string as a number with the same radix and scale as the left hand side
of the equation and then compares them as Numbers. This means that
it's actually more resiliant to minor formatting differences.
Diffstat (limited to 'src/number.cpp')
-rw-r--r-- | src/number.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/number.cpp b/src/number.cpp index d95ab90..062e368 100644 --- a/src/number.cpp +++ b/src/number.cpp | |||
@@ -121,6 +121,12 @@ Number Number::operator-() const | |||
121 | return neg; | 121 | return neg; |
122 | } | 122 | } |
123 | 123 | ||
124 | bool Number::operator==( const Bu::String &rhs ) const | ||
125 | { | ||
126 | Number nrhs( rhs, iScale, iRadix ); | ||
127 | return (*this) == nrhs; | ||
128 | } | ||
129 | |||
124 | bool Number::operator==( const Number &rhs ) const | 130 | bool Number::operator==( const Number &rhs ) const |
125 | { | 131 | { |
126 | if( rhs.bPositive != bPositive || | 132 | if( rhs.bPositive != bPositive || |