Skip to content
Open
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
11 changes: 4 additions & 7 deletions src/asar/math_eval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,17 @@ bool evaluate_binop_compare(const T& lhs, const T& rhs, math_binop_type type) {

static bool evaluate_eq(math_val lhs, math_val rhs) {
// if only one is string, they can never be equal
if((lhs.m_type == math_val_type::string) ^ (rhs.m_type == math_val_type::string)) {
if((lhs.m_type == math_val_type::string) != (rhs.m_type == math_val_type::string)) {
return false;
}
if(lhs.m_type == math_val_type::string) {
// both strings: compare as strings
return lhs.get_str() == rhs.get_str();
} else {
// both non strings: compare as numbers
if(lhs.m_type == math_val_type::floating || rhs.m_type == math_val_type::floating)
// one floating: compare as floats
return lhs.get_double() == rhs.get_double();
else
// both ints: compare as ints
return lhs.get_integer() == rhs.get_integer();
// compare as both types, to ensure rounding errors don't return things like 0x5555555555555555 == 0x5555555555555556+511.0
// (but omit integer compare if that'd overflow)
return lhs.get_double() == rhs.get_double() && (fabs(lhs.get_double()) > INT64_MAX || lhs.get_integer() == rhs.get_integer());
}
}

Expand Down