{"id":211,"date":"2011-08-18T15:53:13","date_gmt":"2011-08-18T13:53:13","guid":{"rendered":"http:\/\/wp.oktay.com\/?p=211"},"modified":"2017-04-05T22:37:31","modified_gmt":"2017-04-05T20:37:31","slug":"ieee-954-dec-float-to-hex","status":"publish","type":"post","link":"https:\/\/wp.oktay.com\/?p=211","title":{"rendered":"ieee 754 &#8211; dec float to hex"},"content":{"rendered":"<p>example : <strong>1280 <\/strong>double in hex = 40 94 00 00 00 00 00 00 as hex<\/p>\n<p>1. log2(1280) = log(1280)\/log(2) = 10<br \/>\n2. 1023 + 10 = HEX 0x409 (this is the exponent)<br \/>\n3. now the mantisse: 1280 \/ (2^10) &lt; -1024 = 1.25 4. 1.25 * 2^52 (^23 for float) = 5.629.499.534.213.120 = BIN 1 0100 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 5. remove the 1st 1 (that for mantisse start) so we would have 100 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 = HEX 0x4 0000 0000 0000 6. 2. -&gt; 0x409 &lt; &lt; 36 | 5.-&gt; 0x4 0000 0000 0000 = hex = 40 94 00 00 00 00 00 00<\/p>\n<p>calc: http:\/\/babbage.cs.qc.edu\/IEEE-754\/Decimal.html<br \/>\nexample: http:\/\/www.wer-weiss-was.de\/theme121\/article3802216.html<\/p>\n","protected":false},"excerpt":{"rendered":"<p>example : 1280 double in hex = 40 94 00 00 00 00 00 00 as hex 1. log2(1280) = log(1280)\/log(2) = 10 2. 1023 + 10 = HEX 0x409 (this is the exponent) 3. now the mantisse: 1280 \/ (2^10) &lt; -1024 = 1.25 4. 1.25 * 2^52 (^23 for float) = 5.629.499.534.213.120 =&hellip; <a class=\"more-link\" href=\"https:\/\/wp.oktay.com\/?p=211\">Continue reading <span class=\"screen-reader-text\">ieee 754 &#8211; dec float to hex<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-211","post","type-post","status-publish","format-standard","hentry","category-math","entry"],"_links":{"self":[{"href":"https:\/\/wp.oktay.com\/index.php?rest_route=\/wp\/v2\/posts\/211","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.oktay.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.oktay.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.oktay.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.oktay.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=211"}],"version-history":[{"count":5,"href":"https:\/\/wp.oktay.com\/index.php?rest_route=\/wp\/v2\/posts\/211\/revisions"}],"predecessor-version":[{"id":673,"href":"https:\/\/wp.oktay.com\/index.php?rest_route=\/wp\/v2\/posts\/211\/revisions\/673"}],"wp:attachment":[{"href":"https:\/\/wp.oktay.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.oktay.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.oktay.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}