{"id":21345,"date":"2018-04-27T16:59:59","date_gmt":"2018-04-27T20:59:59","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=21345"},"modified":"2018-04-27T17:02:03","modified_gmt":"2018-04-27T21:02:03","slug":"javascripts-tricky-rounding","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2018\/04\/27\/javascripts-tricky-rounding\/","title":{"rendered":"JavaScript&rsquo;s Tricky Rounding"},"content":{"rendered":"<p><a href=\"http:\/\/ridiculousfish.com\/blog\/posts\/JavaScript-Rounding.html\">Peter Ammon<\/a>:<\/p>\n<blockquote cite=\"http:\/\/ridiculousfish.com\/blog\/posts\/JavaScript-Rounding.html\">\n<p>Unfortunately, the implementation in the spec does not correctly implement the spec.<\/p>\n<p>[&#8230;]<\/p>\n<p>JavaScript presumably rounds this odd way to match Java, and so the only engine to get it right out of the gate is <a href=\"https:\/\/github.com\/mozilla\/rhino\/blob\/master\/src\/org\/mozilla\/javascript\/NativeMath.java#L234\">Rhino<\/a>, which simply calls back to Java&rsquo;s Math.round. Amusingly Oracle fell into the same trap with Rhino&rsquo;s successor Nashorn. Round and round we go!<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Peter Ammon: Unfortunately, the implementation in the spec does not correctly implement the spec. [&#8230;] JavaScript presumably rounds this odd way to match Java, and so the only engine to get it right out of the gate is Rhino, which simply calls back to Java&rsquo;s Math.round. Amusingly Oracle fell into the same trap with Rhino&rsquo;s [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2018-04-27T21:00:01Z","apple_news_api_id":"9aef3d04-f3c9-4eab-a666-da58cf183878","apple_news_api_modified_at":"2018-04-27T21:02:07Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAAA==","apple_news_api_share_url":"https:\/\/apple.news\/Amu89BPPJTqumZtpYzxg4eA","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[],"tags":[669,84,346,46,259,71],"class_list":["post-21345","post","type-post","status-publish","format-standard","hentry","tag-floating-point","tag-java","tag-javascript","tag-languagedesign","tag-math","tag-programming"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/21345","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=21345"}],"version-history":[{"count":1,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/21345\/revisions"}],"predecessor-version":[{"id":21346,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/21345\/revisions\/21346"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=21345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=21345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=21345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}