Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Users

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #11 (permalink)  
Old 06-25-2008, 06:28 AM
Starter Member
 
Posts: 2
Default

Quote:
Originally Posted by Bill Brock View Post
This may be fodder for another post but it is another document issue.

a1: 5.51% percentage, auto decimal
a2: 6.68% percentage, auto dec.
a3: 7.54% percentage, auto dec.
a4: 19.72999999999... sum a1,a2,a3, percentage, auto decimal

a4 should be 19.73% instead of the 19.729999999... If I force 2 decimals it rounds up to the right answer so I wasn't that concerned. But this is straight addition and the sum is wrong.
This is one of the funniest JS bugs. Execute this code i.e. in Firebug console, or anywhere:

alert(5.51 + 6.68 + 7.54);

It says 19.73. Now try this one:

alert(7.54 + 6.68 + 5.51);

It says 19.729999....97! :-)

The thing is, we compute sums in reverse order as it turns out to be slightly faster.

You can search the web for "javascript floating point bug" and it'll reveal lots of info about it. Unfortunately, I don't see what we could do... In this particular example, we can "fix" by changing the order in which we compute the result, but as you can imagine, it won't help a dime for the general case.

It gets fixed indeed if you manually restrict precision.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.