Bug 144115 - wrong value with leading zero in toFixed() function
Summary: wrong value with leading zero in toFixed() function
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Applications
Component: kjs (show other bugs)
Version: unspecified
Platform: unspecified FreeBSD
: NOR normal
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-04-12 04:32 UTC by Nikolay Pavlov
Modified: 2007-04-20 23:45 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nikolay Pavlov 2007-04-12 04:32:15 UTC
Version:           3.5.6 (using KDE 3.5.6, compiled sources)
Compiler:          gcc version 3.4.6 [FreeBSD] 20060825
OS:                FreeBSD (i386) release 7.0-CURRENT

Try this code on konqueror:

<script>

var kk = 0.1234;

function proc() {
alert ("Leading zero was lost somehow, value is " + kk.toFixed(4) + ", but should be " + kk);
}

</script>
<input type="button" value="Process" onclick="proc()" />
Comment 1 Harri Porten 2007-04-20 23:45:38 UTC
SVN commit 656293 by porten:

Fixed off-by-one digit error in toFixed(). Already fixed in trunk.

BUG: 144115


 M  +6 -0      ChangeLog  
 M  +1 -1      number_object.cpp  


--- branches/KDE/3.5/kdelibs/kjs/ChangeLog #656292:656293
@@ -1,3 +1,9 @@
+2007-04-20  Harri Porten  <porten@kde.org>
+
+	* number_object.cpp: fixed leading-zero loss on toFixed() call by
+	following the spec algorithm properly.  Nikolay Pavlov's bug
+	report: http://bugs.kde.org/144115.
+
 2007-03-13  Harri Porten  <porten@kde.org>
 
 	* function.cpp (decodeURI): don't drop last character of unescaped
--- branches/KDE/3.5/kdelibs/kjs/number_object.cpp #656292:656293
@@ -241,7 +241,7 @@
     UString m = integer_part_noexp(n);
 
     int k = m.size();
-    if (m.size() < f) {
+    if (k <= f) {
       UString z = "";
       for (int i = 0; i < f+1-k; i++)
 	z += "0";