{"id":7847,"date":"2026-11-07T00:01:59","date_gmt":"2026-11-07T08:01:59","guid":{"rendered":"https:\/\/c-for-dummies.com\/blog\/?p=7847"},"modified":"2026-10-31T13:09:41","modified_gmt":"2026-10-31T20:09:41","slug":"the-magic-behind-real-numbers","status":"publish","type":"post","link":"https:\/\/c-for-dummies.com\/blog\/?p=7847","title":{"rendered":"The Magic Behind Real Numbers"},"content":{"rendered":"<p>Continuing from <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=7842\">last week&#8217;s Lesson<\/a>, the puzzle I&#8217;m trying to solve is how the computer manipulates the integer values zero, 0x82 and 0x460000 to arrive at 13.375. The answer lies in the binary32 format used to represent real numbers. To store 13.375 in a binary format involves a bit of conjuring.<br \/>\n<!--more--><br \/>\nAs with all computer magic, the result must be predictable. And the pipe must flow both ways: You can translate 13.375 into various bits in a manner that ensures they are translated back &mdash; with as much accuracy as possible.<\/p>\n<p>To make the conversion, you must know three weirdo techy tidbits:<\/p>\n<ul>\n<li>Binary fractions<\/li>\n<li>Binary scientific notation<\/li>\n<li>The IEEE 754 standard bias of 127<\/li>\n<\/ul>\n<p>The first step involves converting the value into its binary portions: The integer part before the decimal point and the fractional part after the decimal point. I&#8217;ve covered <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=2022\">binary fractions<\/a> before, though I&#8217;ll repeat some of this information in next week&#8217;s Lesson where I dive into the details.<\/p>\n<p>The completion of the first step involves gluing the integer and fraction forms together to form a single binary value, something like 1101.011 for 13.375.<\/p>\n<p>The second step is to create a binary scientific notation for the glued-together value. For the example of 1101.011, the decimal place is shifted three positions to the left: 1.101011. The three is important as it represents the exponent. The binary scientific notation value is now 1.101011 &times; 2<sup>3<\/sup>. But the translation isn&#8217;t done at this point.<\/p>\n<p>The third step is to manipulate the exponent value by the &#8220;standard bias&#8221; of 127. So 3 (the power) is added to 127 to get 130, or 10000010. This value is 0x82, which is seen in the binary32 format for 13.375 at the top of this post.<\/p>\n<p>Finally, the initial one is lopped off the value 1.101011 to yield 101011. This is where the value 0x460000 comes from: For binary32, this value must be 23 bits long. Again, the initial 1 is implied in the format.<\/p>\n<p>All together, these elements create the real number.<\/p>\n<p>The good news is that the processor does the work for you, converting values from bits into a real number. You could manually attempt to do so, and I&#8217;ve tried, but it takes more overhead to code such action when the processor does the job innately. For fun, however, I will continue to explore some of these concepts, starting a deep dive into binary fractions for next week&#8217;s Lesson.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The binary32 format for storing a real number is clever but not obvious. <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=7847\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-7847","post","type-post","status-publish","format-standard","hentry","category-main"],"_links":{"self":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7847","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7847"}],"version-history":[{"count":5,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7847\/revisions"}],"predecessor-version":[{"id":7879,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7847\/revisions\/7879"}],"wp:attachment":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7847"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7847"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7847"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}