{"id":5410,"date":"2014-03-30T21:39:56","date_gmt":"2014-03-30T21:39:56","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/private-static-final-double-is-0-collection-of-common-programming-errors\/"},"modified":"2014-03-30T21:39:56","modified_gmt":"2014-03-30T21:39:56","slug":"private-static-final-double-is-0-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/private-static-final-double-is-0-collection-of-common-programming-errors\/","title":{"rendered":"private static final double is 0-Collection of common programming errors"},"content":{"rendered":"<p>The constant ends up with a value of <code>0.0<\/code> because the result of integer division is an integer, truncated. So your the value of your initialization is <code>0<\/code>, not <code>0.5<\/code>. To force a <code>double<\/code> result, make one or both of the operands a <code>double<\/code>:<\/p>\n<pre><code>private static final double CONSTANT = 1\/2.0;  \/\/ or 1\/2D, or even 1D\/2D \n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The constant ends up with a value of 0.0 because the result of integer division is an integer, truncated. So your the value of your initialization is 0, not 0.5. To force a double result, make one or both of the operands a double: private static final double CONSTANT = 1\/2.0; \/\/ or 1\/2D, or [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5410","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5410","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5410"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5410\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5410"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5410"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5410"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}