{"id":77,"date":"2022-05-10T15:56:57","date_gmt":"2022-05-10T14:56:57","guid":{"rendered":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phsn5computingscience\/?page_id=77"},"modified":"2022-05-10T16:10:50","modified_gmt":"2022-05-10T15:10:50","slug":"floating-point-representation","status":"publish","type":"page","link":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phsn5computingscience\/floating-point-representation\/","title":{"rendered":"Floating Point Representation"},"content":{"rendered":"<h2 style=\"color: red\"><b><span data-contrast=\"auto\">What is a Real Number<\/span><\/b><\/h2>\n<ul style=\"font-weight: 400\">\n<li data-aria-posinset=\"1\" data-aria-level=\"1\"><span data-contrast=\"none\">Integer = whole number\u00a0<\/span><\/li>\n<\/ul>\n<p style=\"color: red\">\u00a0 \u00a0 \u00a0 \u00a01, 4, 67, 1234, 134567, -12<\/p>\n<ul style=\"font-weight: 400\">\n<li data-aria-posinset=\"2\" data-aria-level=\"1\"><span data-contrast=\"none\">Real Number = Decimal numbers<\/span><\/li>\n<\/ul>\n<p style=\"color: red\">\u00a0 \u00a0 \u00a0\u00a01.25, 158.54, 7895.36, -45.56<\/p>\n<h3 style=\"color: red\"><b><span data-contrast=\"none\">Representing Real Numbers\u00a0<\/span><\/b><\/h3>\n<ul style=\"font-weight: 400\">\n<li data-aria-posinset=\"3\" data-aria-level=\"1\"><span data-contrast=\"none\">Real numbers always contain a decimal point (.)<\/span><\/li>\n<li data-aria-posinset=\"4\" data-aria-level=\"1\"><span data-contrast=\"none\">But \u2013 the decimal point (.) cannot be stored in binary!<\/span><\/li>\n<li data-aria-posinset=\"5\" data-aria-level=\"1\"><span data-contrast=\"none\">However, if we can represent a real number with<\/span><span data-contrast=\"none\">\u00a0<\/span><span data-contrast=\"none\">the decimal point always in the same place<\/span><span data-contrast=\"none\">\u00a0<\/span><span data-contrast=\"none\">then we don\u2019t need to store the decimal point!<\/span><\/li>\n<\/ul>\n<p><span data-contrast=\"none\">Fortunately such a system exists!<\/span><\/p>\n<p><b><span data-contrast=\"none\">SCIENTIFIC NOTATION<\/span><\/b><\/p>\n<p><span data-contrast=\"none\">Examples:<\/span><\/p>\n<p><span data-contrast=\"none\">123456.7\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 =\u00a0\u00a0\u00a0 0.1234567 x 10<\/span><span data-contrast=\"none\">6<\/span><\/p>\n<p><span data-contrast=\"none\">0.001234\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 =\u00a0\u00a0\u00a0 0.1234 x 10<\/span><span data-contrast=\"none\">-2<\/span><\/p>\n<p><span data-contrast=\"none\">1234.567\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 =\u00a0\u00a0\u00a0 0.1234567 x 10<\/span><span data-contrast=\"none\">4<\/span><\/p>\n<p><span data-contrast=\"none\">All<\/span><span data-contrast=\"none\">\u00a0real numbers can be written in this common and consistent format<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-82\" src=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/10160257\/Screenshot-2022-05-10-160235-300x129.png\" alt=\"\" width=\"734\" height=\"316\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/10160257\/Screenshot-2022-05-10-160235-300x129.png 300w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/10160257\/Screenshot-2022-05-10-160235-1024x440.png 1024w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/10160257\/Screenshot-2022-05-10-160235-768x330.png 768w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/10160257\/Screenshot-2022-05-10-160235-624x268.png 624w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/10160257\/Screenshot-2022-05-10-160235.png 1260w\" sizes=\"auto, (max-width: 734px) 100vw, 734px\" \/><\/p>\n<p><span data-contrast=\"none\">Real numbers are always stored in two parts:<\/span><\/p>\n<ul>\n<li data-aria-posinset=\"1\" data-aria-level=\"2\"><span data-contrast=\"none\">The first part holds the mantissa converted into binary<\/span><\/li>\n<li data-aria-posinset=\"2\" data-aria-level=\"2\"><span data-contrast=\"none\">The second part holds the exponent also converted into binary<\/span><\/li>\n<\/ul>\n<p><span data-contrast=\"none\">The\u00a0<\/span><strong>mantissa<\/strong><span data-contrast=\"none\"><strong>\u00a0<\/strong>is the actual digits of the numbers, <\/span><span data-contrast=\"none\">this is the size of the number\u00a0<\/span><\/p>\n<p><span data-contrast=\"none\">The\u00a0<\/span><strong>exponent<\/strong><span data-contrast=\"none\"><strong>\u00a0<\/strong>is the power to which the base is raised, this s<\/span><span data-contrast=\"none\">tores the number of places to move the decimal point<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-85\" src=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/10160545\/Screenshot-2022-05-10-160516-300x157.png\" alt=\"\" width=\"661\" height=\"346\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/10160545\/Screenshot-2022-05-10-160516-300x157.png 300w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/10160545\/Screenshot-2022-05-10-160516-1024x537.png 1024w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/10160545\/Screenshot-2022-05-10-160516-768x403.png 768w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/10160545\/Screenshot-2022-05-10-160516-624x327.png 624w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phsn5computingscience\/uploads\/sites\/10033\/2022\/05\/10160545\/Screenshot-2022-05-10-160516.png 1260w\" sizes=\"auto, (max-width: 661px) 100vw, 661px\" \/><\/p>\n<p>Changing the number of bits used to hold the mantissa or the exponent affects the number.<\/p>\n<ul style=\"font-weight: 400\">\n<li data-aria-posinset=\"1\" data-aria-level=\"2\"><strong>Increasing\u00a0<\/strong>the number of bits used for the\u00a0<strong>mantissa\u00a0<\/strong>increases the\u00a0<strong>accuracy\u00a0<\/strong>to which the number is stored<\/li>\n<li data-aria-posinset=\"2\" data-aria-level=\"2\"><strong>Increasing\u00a0<\/strong>the number of bits used for the\u00a0<strong>exponent\u00a0<\/strong>increases\u00a0the\u00a0<strong>range\u00a0<\/strong>of numbers that can be stored<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>What is a Real Number Integer = whole number\u00a0 \u00a0 \u00a0 \u00a0 \u00a01, 4, 67, 1234, 134567, -12 Real Number = Decimal numbers \u00a0 \u00a0 \u00a0\u00a01.25, 158.54, 7895.36, -45.56 Representing Real Numbers\u00a0 Real numbers always contain a decimal point (.) But \u2013 the decimal point (.) cannot be stored in binary! However, if we can [&hellip;]<\/p>\n","protected":false},"author":79984,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-77","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phsn5computingscience\/wp-json\/wp\/v2\/pages\/77","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phsn5computingscience\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phsn5computingscience\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phsn5computingscience\/wp-json\/wp\/v2\/users\/79984"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phsn5computingscience\/wp-json\/wp\/v2\/comments?post=77"}],"version-history":[{"count":8,"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phsn5computingscience\/wp-json\/wp\/v2\/pages\/77\/revisions"}],"predecessor-version":[{"id":89,"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phsn5computingscience\/wp-json\/wp\/v2\/pages\/77\/revisions\/89"}],"wp:attachment":[{"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phsn5computingscience\/wp-json\/wp\/v2\/media?parent=77"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}