Okay, what if we changed line 90 of NumberFormat.js from:
    var integerDigits = Math.max(parseInt(Math.log(num) / Math.LN10) + 1,
1);
to:
    var integerDigits = (String(Math.floor(num)).length);
That should always give the appropriate length, though it is a little more
of a hack. I've tested it out a bit myself, and it seems to work alright.
Any thoughts?

-Dan


MootCycle wrote:
> 
> Well, I found the problem, and it seems like it is a rounding error in
> javascript:
> 
> 005959 DEBUG: qx.util.format.NumberFormat[18]: num => 1000 -- str => 100
> -- result =>3
> 005962 DEBUG: qx.util.format.NumberFormat[18]: Math.log(num) =>
> 6.907755278982137
> 005965 DEBUG: qx.util.format.NumberFormat[18]: (Math.log(num) / Math.LN10)
> => 2.9999999999999996
> 005968 DEBUG: qx.util.format.NumberFormat[18]: parseInt(Math.log(num) /
> Math.LN10) => 2
> 005971 DEBUG: qx.util.format.NumberFormat[18]:
> Math.max(parseInt(Math.log(num) / Math.LN10) + 1, 1) => 3
> 
> Log(1000)/Log(10) should equal 3. but javascript calculates it to 2.99.
> Log(x)/Log(10) can't just be rounded up because then other values passed
> in will calculate incorrectly. I'll keep looking at this, but if someone
> else already has a solution, please let me know.
> 
> -Dan
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Bug%3A-Number-Formatting-in-the-Table-Object--tf3124813.html#a8702780
Sent from the qooxdoo-devel mailing list archive at Nabble.com.


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to