{"id":96,"date":"2010-06-24T11:25:44","date_gmt":"2010-06-24T10:25:44","guid":{"rendered":"https:\/\/base6.com\/?p=96"},"modified":"2010-06-25T08:08:09","modified_gmt":"2010-06-25T07:08:09","slug":"calculating-floating-point-epsilonprecision-in-java","status":"publish","type":"post","link":"https:\/\/base6.com\/2010\/06\/24\/calculating-floating-point-epsilonprecision-in-java\/","title":{"rendered":"Calculating floating point epsilon\/precision in Java"},"content":{"rendered":"

Floating point arithmetic\/rounding can be somewhat painful, made worse by the fact that the epsilon (error) in the machine representation of floating point varies depending on the exponent (i.e. how large\/small the number being represented is):<\/p>\n

\"\"<\/p>\n

Normalized numbers when Base = 2, Precision = 3, Exponents = -1 to 2 [Goldberg91<\/a>]<\/p>\n<\/div>\n

A very comprehensive paper (from which the above image is taken) is available here<\/a>. In previous teams we have implemented our own functions to derive an approximation of the epsilon from the number to be represented, however I discovered recently to my surprise that such a function was added to Java in 1.5: Math.ulp<\/a>!<\/p>\n","protected":false},"excerpt":{"rendered":"

Floating point arithmetic\/rounding can be somewhat painful, made worse by the fact that the epsilon (error) in the machine representation of floating point varies depending on the exponent (i.e. how large\/small the number being represented is): Normalized numbers when Base = 2, Precision = 3, Exponents = -1 to 2 [Goldberg91] A very comprehensive paper […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[9233,6416,1109,60282,3906],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/base6.com\/wp-json\/wp\/v2\/posts\/96"}],"collection":[{"href":"https:\/\/base6.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/base6.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/base6.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/base6.com\/wp-json\/wp\/v2\/comments?post=96"}],"version-history":[{"count":13,"href":"https:\/\/base6.com\/wp-json\/wp\/v2\/posts\/96\/revisions"}],"predecessor-version":[{"id":101,"href":"https:\/\/base6.com\/wp-json\/wp\/v2\/posts\/96\/revisions\/101"}],"wp:attachment":[{"href":"https:\/\/base6.com\/wp-json\/wp\/v2\/media?parent=96"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/base6.com\/wp-json\/wp\/v2\/categories?post=96"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/base6.com\/wp-json\/wp\/v2\/tags?post=96"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}