Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 41 additions & 6 deletions src/types/decimal/decimal.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,14 @@ class Decimal {
* @return
*/
bool operator==(const Decimal &dec) const {
return v == dec.getMpf();
const mpf_class& mpf1 = mpf_class(toString());
const mpf_class& mpf2 = mpf_class(dec.toString());

int ret = cmp(mpf1, mpf2);
if(ret == 0) {
return true;
}
return false;
}

/**
Expand All @@ -228,7 +235,7 @@ class Decimal {
* @return
*/
bool operator!=(const Decimal &dec) const {
return v != dec.getMpf();
return !(*this == dec);
}

/**
Expand All @@ -237,7 +244,14 @@ class Decimal {
* @return
*/
bool operator<(const Decimal &dec) const {
return v < dec.getMpf();
const mpf_class& mpf1 = mpf_class(toString());
const mpf_class& mpf2 = mpf_class(dec.toString());

int ret = cmp(mpf1, mpf2);
if(ret < 0) {
return true;
}
return false;
}

/**
Expand All @@ -246,7 +260,14 @@ class Decimal {
* @return
*/
bool operator<=(const Decimal &dec) const {
return v <= dec.getMpf();
const mpf_class& mpf1 = mpf_class(toString());
const mpf_class& mpf2 = mpf_class(dec.toString());

int ret = cmp(mpf1, mpf2);
if(ret <= 0) {
return true;
}
return false;
}

/**
Expand All @@ -255,7 +276,14 @@ class Decimal {
* @return
*/
bool operator>(const Decimal &dec) const {
return v > dec.getMpf();;
const mpf_class& mpf1 = mpf_class(toString());
const mpf_class& mpf2 = mpf_class(dec.toString());

int ret = cmp(mpf1, mpf2);
if(ret > 0) {
return true;
}
return false;
}

/**
Expand All @@ -264,7 +292,14 @@ class Decimal {
* @return
*/
bool operator>=(const Decimal &dec) const {
return v >= dec.getMpf();
const mpf_class& mpf1 = mpf_class(toString());
const mpf_class& mpf2 = mpf_class(dec.toString());

int ret = cmp(mpf1, mpf2);
if(ret >= 0) {
return true;
}
return false;
}

/**
Expand Down