Browse Source

fixed 0.0 and -0.0 comparison

albertodemichelis 6 years ago
parent
commit
a120da4974
1 changed files with 8 additions and 2 deletions
  1. 8 2
      squirrel/sqvm.cpp

+ 8 - 2
squirrel/sqvm.cpp

@@ -641,8 +641,14 @@ bool SQVM::CLASS_OP(SQObjectPtr &target,SQInteger baseclass,SQInteger attributes
 
 bool SQVM::IsEqual(const SQObjectPtr &o1,const SQObjectPtr &o2,bool &res)
 {
-    if(sq_type(o1) == sq_type(o2)) {
-        res = (_rawval(o1) == _rawval(o2));
+	SQObjectType t1 = sq_type(o1), t2 = sq_type(o2);
+    if(t1 == t2) {
+		if (t1 == OT_FLOAT) {
+			res = (_float(o1) == _float(o2));
+		}
+		else {
+			res = (_rawval(o1) == _rawval(o2));
+		}
     }
     else {
         if(sq_isnumeric(o1) && sq_isnumeric(o2)) {