Skip to content

Commit

Permalink
Fixed binary expression value for epsilon on double value comparison …
Browse files Browse the repository at this point in the history
…operation.
  • Loading branch information
nthnn committed Oct 9, 2024
1 parent 5751fa9 commit e58efce
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/ast/expression/BinaryExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <parser/Token.hpp>
#include <util/VectorMath.hpp>

#include <limits>
#include <memory>
#include <regex>

Expand Down Expand Up @@ -113,9 +114,11 @@ DynamicObject BinaryExpression::applyNumOp(DynamicObject& lValue, DynamicObject&
else if(this->op == "<=")
return DynamicObject(lValue.getNumber() <= rValue.getNumber());
else if(this->op == "==")
return DynamicObject(std::fabs(lValue.getNumber() - rValue.getNumber()) < __DBL_EPSILON__);
return DynamicObject(std::fabs(lValue.getNumber() - rValue.getNumber()) <
std::numeric_limits<double>::epsilon());
else if(this->op == "!=")
return DynamicObject(std::fabs(lValue.getNumber() - rValue.getNumber()) >= __DBL_EPSILON__);
return DynamicObject(std::fabs(lValue.getNumber() - rValue.getNumber()) >=
std::numeric_limits<double>::epsilon());
else if(this->op == "<<")
return DynamicObject((float) ((unsigned long) lValue.getNumber() << (unsigned long) rValue.getNumber()));
else if(this->op == ">>")
Expand Down

0 comments on commit e58efce

Please sign in to comment.