{"action":"created","issue":{"url":"https://api.github.com/repos/foretagsplatsen/numbro/issues/64","labels_url":"https://api.github.com/repos/foretagsplatsen/numbro/issues/64/labels{/name}","comments_url":"https://api.github.com/repos/foretagsplatsen/numbro/issues/64/comments","events_url":"https://api.github.com/repos/foretagsplatsen/numbro/issues/64/events","html_url":"https://github.com/foretagsplatsen/numbro/issues/64","id":90439732,"number":64,"title":"multiply loses accuracy on minification","user":{"login":"rafde","id":833429,"avatar_url":"https://avatars.githubusercontent.com/u/833429?v=3","gravatar_id":"","url":"https://api.github.com/users/rafde","html_url":"https://github.com/rafde","followers_url":"https://api.github.com/users/rafde/followers","following_url":"https://api.github.com/users/rafde/following{/other_user}","gists_url":"https://api.github.com/users/rafde/gists{/gist_id}","starred_url":"https://api.github.com/users/rafde/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rafde/subscriptions","organizations_url":"https://api.github.com/users/rafde/orgs","repos_url":"https://api.github.com/users/rafde/repos","events_url":"https://api.github.com/users/rafde/events{/privacy}","received_events_url":"https://api.github.com/users/rafde/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-06-23T17:04:03Z","updated_at":"2015-06-29T15:20:39Z","closed_at":null,"body":"This is a problem that was noticed at my work for numeraljs\r\nhttps://github.com/foretagsplatsen/numbro/blob/develop/numbro.js#L930-L937\r\nwhere\r\n```\r\n...\r\nvar corrFactor = correctionFactor(accum, curr);\r\nreturn (accum * corrFactor) * (curr * corrFactor) /\r\n    (corrFactor * corrFactor);\r\n```\r\nthe minifier will remove all those parenthesis and mess up the order of operation.\r\nA more cumbersome but accurate solution:\r\n```\r\nvar corrFactor = correctionFactor(accum, curr),\r\n      result = accum * corrFactor;\r\n      result *= curr * corrFactor;\r\n      result /= corrFactor * corrFactor\r\nreturn result;\r\n```\r\nor however you see fit, so long as the order is maintain after minifying.\r\nTest against\r\n`numbro(46.6).multiply(0.575) === 26.795`\r\n"},"comment":{"url":"https://api.github.com/repos/foretagsplatsen/numbro/issues/comments/116729026","html_url":"https://github.com/foretagsplatsen/numbro/issues/64#issuecomment-116729026","issue_url":"https://api.github.com/repos/foretagsplatsen/numbro/issues/64","id":116729026,"user":{"login":"rafde","id":833429,"avatar_url":"https://avatars.githubusercontent.com/u/833429?v=3","gravatar_id":"","url":"https://api.github.com/users/rafde","html_url":"https://github.com/rafde","followers_url":"https://api.github.com/users/rafde/followers","following_url":"https://api.github.com/users/rafde/following{/other_user}","gists_url":"https://api.github.com/users/rafde/gists{/gist_id}","starred_url":"https://api.github.com/users/rafde/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rafde/subscriptions","organizations_url":"https://api.github.com/users/rafde/orgs","repos_url":"https://api.github.com/users/rafde/repos","events_url":"https://api.github.com/users/rafde/events{/privacy}","received_events_url":"https://api.github.com/users/rafde/received_events","type":"User","site_admin":false},"created_at":"2015-06-29T15:20:39Z","updated_at":"2015-06-29T15:20:39Z","body":"When do patches happen?"}}