toInt32() fix

Harri Porten harri at froglogic.com
Sun Jul 27 18:55:28 CEST 2003


date: 2003/07/24 11:44:39;  author: porten;  state: Exp;  lines: +5 -0
patch suggested by Maks Orlovich to always make the modulo positive.
=============================================================================
cvs -f diff -kk -bp -u -r1.29 -r1.30 value.cpp
Index: value.cpp
===================================================================
RCS file: /home/kde/kdelibs/kjs/value.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -b -p -u -r1.29 -r1.30
--- value.cpp   9 Mar 2003 22:23:59 -0000       1.29
+++ value.cpp   24 Jul 2003 11:44:39 -0000      1.30
@@ -111,6 +111,11 @@ int ValueImp::toInt32(ExecState *exec) c
   double d = roundValue(exec, Value(const_cast<ValueImp*>(this)));
   double d32 = fmod(d, D32);
 
+  //Make sure we use the positive remainder. This matters since this
may be
+  //less than MIN_INT (but still < 2^32), and we don't want the cast to
clamp.
+  if (d32 < 0)
+    d32 += D32;
+
   if (d32 >= D32 / 2.0)
     d32 -= D32;


More information about the Khtml-devel mailing list