Per Cederberg wrote:
> Christoph Zwerschke wrote:
>>  The roundToFixed should be also much simpler:
>>
>>  function roundToFixed(aNumber, precision) {
>>      var res = aNumber.toFixed(precision);
>>      if (res.charAt(0) == ".") {
>>          res = "0" + res;
>>      }
>>      return res;
>>  };
> 
> Yes, in theory this is correct. But Safari 3.1 (on Mac) still
> truncates instead of rounds, hence the following:
> 
>     0.15.toFixed(1)  ==> "0.1"
> 
> So we still need roundToFixed() and truncToFixed() to provided
> consistent behavior across browsers, unfortunately.

The problem here is that 0.15 is a number that cannot be represented 
exactly in the binary system. In this case, Firefox 2 and 3 and Opera 9 
round down to 0.1 as well. In fact, I would have assumed all browsers 
do, but I just noticed that MSIE 7 indeed rounds 0.15 up to 0.2 :-(

-- Christoph

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to