{"id":311,"date":"2010-09-20T12:48:53","date_gmt":"2010-09-20T16:48:53","guid":{"rendered":"http:\/\/brendyn.com\/blog\/?p=311"},"modified":"2010-09-20T12:49:26","modified_gmt":"2010-09-20T16:49:26","slug":"math-calculations-in-flash-return-wrong-number-with-lots-of-decimals","status":"publish","type":"post","link":"http:\/\/brendyn.com\/blog\/archives\/311","title":{"rendered":"Math calculations in Flash return wrong number with lots of decimals&#8230;"},"content":{"rendered":"<p>&#8230;In other words, a Floating Point Error, or so my web research says.<\/p>\n<p>Apparently, in all coding languages (not just Flash), a decimal does not have an exact representation in binary. So, for example, 5.100000000000000001 is seen as close enough to 5.1. This is fine when doing other things, such as moving a Movie Clip to an x position, but if you are coding something such as a calculator when you need to display the exact number, it can be frustrating.<\/p>\n<p>I found a <a href=\"http:\/\/joshblog.net\/2007\/01\/30\/flash-floating-point-number-errors\/\" target=\"_blank\">method online<\/a> that corrects this by comparing a few numbers, and estimating. Seems to do the trick in my case.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8230;In other words, a Floating Point Error, or so my web research says. Apparently, in all coding languages (not just [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0},"categories":[5,11],"tags":[],"_links":{"self":[{"href":"http:\/\/brendyn.com\/blog\/wp-json\/wp\/v2\/posts\/311"}],"collection":[{"href":"http:\/\/brendyn.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/brendyn.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/brendyn.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/brendyn.com\/blog\/wp-json\/wp\/v2\/comments?post=311"}],"version-history":[{"count":2,"href":"http:\/\/brendyn.com\/blog\/wp-json\/wp\/v2\/posts\/311\/revisions"}],"predecessor-version":[{"id":313,"href":"http:\/\/brendyn.com\/blog\/wp-json\/wp\/v2\/posts\/311\/revisions\/313"}],"wp:attachment":[{"href":"http:\/\/brendyn.com\/blog\/wp-json\/wp\/v2\/media?parent=311"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/brendyn.com\/blog\/wp-json\/wp\/v2\/categories?post=311"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/brendyn.com\/blog\/wp-json\/wp\/v2\/tags?post=311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}