{"id":1616,"date":"2015-04-23T19:41:13","date_gmt":"2015-04-23T14:11:13","guid":{"rendered":"http:\/\/judepereira.com\/blog\/?p=1616"},"modified":"2015-04-23T20:06:16","modified_gmt":"2015-04-23T14:36:16","slug":"0f-float-min_value-false","status":"publish","type":"post","link":"https:\/\/judepereira.com\/blog\/0f-float-min_value-false\/","title":{"rendered":"0f > Float.MIN_VALUE = false!"},"content":{"rendered":"<p><strong>Updates:<\/strong><br \/>\nTurns out that this is the expected behaviour from the java doc:<br \/>\n<i>A constant holding the smallest positive nonzero value of type float, 2<sup>-149<\/sup>.<\/i><\/p>\n<p>So now, how do I get the <strong>smallest negative value<\/strong> that a float can hold?<\/p>\n<hr>\n<p>Just came across the most weirdest thing ever in Java &#8211; <em>0f > Float.MIN_VALUE<\/em> returns <strong>false<\/strong>!<\/p>\n<p>Similarly, anything less than 0, (say -10 for example) is surprisingly not greater than Float.MIN_VALUE.<\/p>\n<p>However, <em>0 > Integer.MIN_VALUE<\/em> returns true!<\/p>\n<p>Want to try it out?<\/p>\n<p>[code lang=&#8217;java&#8217;]<br \/>\npublic class E {<br \/>\n    public static void main(String[] args) {<br \/>\n        System.out.println(&#8220;1f > Float.MIN_VALUE: &#8221; + (1f > Float.MIN_VALUE));<br \/>\n        System.out.println(&#8220;0f > Float.MIN_VALUE: &#8221; + (0f > Float.MIN_VALUE));<br \/>\n        System.out.println(&#8220;-1f > Float.MIN_VALUE: &#8221; + (-1f > Float.MIN_VALUE));<br \/>\n        System.out.println(&#8220;0f < Float.MIN_VALUE: \" + (0f < Float.MIN_VALUE));\n        System.out.println(\"0f == Float.MIN_VALUE: \" + (0f == Float.MIN_VALUE));\n    }\n}\n[\/code]\n\nResult:\n\n\n<pre>\r\n1f > Float.MIN_VALUE: true\r\n0f > Float.MIN_VALUE: false\r\n-1f > Float.MIN_VALUE: false\r\n0f < Float.MIN_VALUE: true\r\n0f == Float.MIN_VALUE: false\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Updates: Turns out that this is the expected behaviour from the java doc: A constant holding the smallest positive nonzero value of type float, 2-149. So now, how do I get the smallest negative value that a float can hold? Just came across the most weirdest thing ever in Java &#8211; 0f > Float.MIN_VALUE returns [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[12],"tags":[523,524,525,463,527,526],"class_list":["post-1616","post","type-post","status-publish","format-standard","hentry","category-misc","tag-float","tag-int","tag-integer","tag-java","tag-max_value","tag-min_value"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pqtyx-q4","jetpack-related-posts":[{"id":1824,"url":"https:\/\/judepereira.com\/blog\/java-9s-httpclient-doesnt-allow-custom-http-2-authorization-headers\/","url_meta":{"origin":1616,"position":0},"title":"Java 9&#8217;s HttpClient doesn&#8217;t allow custom HTTP\/2 authorization headers","author":"Jude Pereira","date":"January 23, 2018","format":false,"excerpt":"TL;DR Java 9 HttpClient does not allow custom Authorization header unless you resort to a hack. Read more about my blog post on CleverTap's blog.","rel":"","context":"In &quot;miscellaneous&quot;","block_context":{"text":"miscellaneous","link":"https:\/\/judepereira.com\/blog\/category\/misc\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1845,"url":"https:\/\/judepereira.com\/blog\/intellij-on-steroids-with-g1-gc\/","url_meta":{"origin":1616,"position":1},"title":"IntelliJ on steroids with G1 GC","author":"Jude Pereira","date":"June 15, 2018","format":false,"excerpt":"Lately, I noticed that IntelliJ started to pause for quite some time during it's GC cycles, and that it was very frequent when I was editing three files (over 1.2k LOC each) split vertically. The current version of IntelliJ runs on a bundled version of Java 1.8, who's default garbage\u2026","rel":"","context":"In &quot;another snippet | code&quot;","block_context":{"text":"another snippet | code","link":"https:\/\/judepereira.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1936,"url":"https:\/\/judepereira.com\/blog\/taming-a-throttled-api-with-dynamic-proxies-in-java\/","url_meta":{"origin":1616,"position":2},"title":"Taming a throttled API with Dynamic Proxies in Java","author":"Jude Pereira","date":"January 20, 2021","format":false,"excerpt":"Recently, at CleverTap, we've begun migrating some of our largest clusters to a new protocol (for starters, think ~115 instances at a time). One of the most fun things I've had my hands on during this migration was the AWS Systems Manager API. When we scaled up our migrations gradually\u2026","rel":"","context":"In &quot;another snippet | code&quot;","block_context":{"text":"another snippet | code","link":"https:\/\/judepereira.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1696,"url":"https:\/\/judepereira.com\/blog\/mocking-the-http2-apple-push-notification-gateway-in-go\/","url_meta":{"origin":1616,"position":3},"title":"Mocking the HTTP\/2 Apple push notification gateway in Go","author":"Jude Pereira","date":"February 17, 2016","format":false,"excerpt":"At CleverTap, we had the need to mock the new HTTP\/2 Apple push gateway API. After trying to do this in Java, and then in Python, I succeeded in getting it to work in Go. Go out of all languages! To me, Go has a completely strange syntax, compared to\u2026","rel":"","context":"In &quot;another snippet | code&quot;","block_context":{"text":"another snippet | code","link":"https:\/\/judepereira.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1675,"url":"https:\/\/judepereira.com\/blog\/sending-notifications-via-apples-new-http2-api-using-jetty-9-3-6\/","url_meta":{"origin":1616,"position":4},"title":"Sending notifications via Apple&#8217;s new HTTP\/2 API (using Jetty 9.3.6)","author":"Jude Pereira","date":"January 9, 2016","format":false,"excerpt":"HTTP\/2 is still very much new to Java, and as such, there are just two libraries who support it - Jetty (from 9.3), and Netty (in alpha). If you're going the Jetty way (as I have), you'll need to add their ALPN library to your boot classpath. Note: Jetty 9.3.x\u2026","rel":"","context":"In &quot;another snippet | code&quot;","block_context":{"text":"another snippet | code","link":"https:\/\/judepereira.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1986,"url":"https:\/\/judepereira.com\/blog\/kiss-hand-crafted-json-is-not-faster-than-objectmapper\/","url_meta":{"origin":1616,"position":5},"title":"KISS: Hand crafted JSON is NOT faster than ObjectMapper","author":"Jude Pereira","date":"September 4, 2023","format":false,"excerpt":"Premature optimisations are evil. Apart from being buggy, they might actually be slower than the industry standard.","rel":"","context":"In &quot;another snippet | code&quot;","block_context":{"text":"another snippet | code","link":"https:\/\/judepereira.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/posts\/1616","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/comments?post=1616"}],"version-history":[{"count":7,"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/posts\/1616\/revisions"}],"predecessor-version":[{"id":1623,"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/posts\/1616\/revisions\/1623"}],"wp:attachment":[{"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/media?parent=1616"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/categories?post=1616"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/tags?post=1616"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}