{"id":53,"date":"2022-05-16T20:41:17","date_gmt":"2022-05-16T19:41:17","guid":{"rendered":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phshighercomputingscience\/?page_id=53"},"modified":"2022-05-16T20:48:14","modified_gmt":"2022-05-16T19:48:14","slug":"floating-point","status":"publish","type":"page","link":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phshighercomputingscience\/floating-point\/","title":{"rendered":"Floating Point"},"content":{"rendered":"<p><span data-contrast=\"auto\">In floating point notation, the real number is stored as 2 separate bits of data<\/span><\/p>\n<ol>\n<li data-aria-posinset=\"1\" data-aria-level=\"2\"><span data-contrast=\"auto\">A storage location called the\u00a0<\/span><b><span data-contrast=\"none\">mantissa<\/span><\/b><span data-contrast=\"auto\">\u00a0holds the complete number without the point.<\/span><\/li>\n<li data-aria-posinset=\"2\" data-aria-level=\"2\"><span data-contrast=\"auto\">A storage location called the\u00a0<\/span><b><span data-contrast=\"none\">exponent<\/span><\/b><span data-contrast=\"auto\">\u00a0holds the number of places that the point must be moved in the original number to place it at the left hand side.<\/span><\/li>\n<\/ol>\n<p><strong>To Work out the mantissa and exponent you need to\u00a0<\/strong><\/p>\n<ul style=\"font-weight: 400\">\n<li data-aria-posinset=\"1\" data-aria-level=\"2\"><span data-contrast=\"auto\">Move the point all the way so the number is a fractional number<\/span><\/li>\n<li data-aria-posinset=\"2\" data-aria-level=\"2\"><span data-contrast=\"auto\">The entire number without the point is the mantissa\u00a0<\/span><\/li>\n<li data-aria-posinset=\"3\" data-aria-level=\"2\"><span data-contrast=\"auto\">The number of places the point was moved is the exponent<\/span><\/li>\n<\/ul>\n<h2 style=\"color: red\"><span class=\"TextRun SCXO149968594 BCX8\" lang=\"EN-GB\" xml:lang=\"EN-GB\" data-contrast=\"none\"><span class=\"NormalTextRun SCXO149968594 BCX8\">Example 1<\/span><\/span><span class=\"EOP SCXO149968594 BCX8\">\u00a0<\/span><\/h2>\n<p><span class=\"TextRun SCXO131545408 BCX8\" lang=\"EN-GB\" xml:lang=\"EN-GB\" data-contrast=\"none\"><span class=\"NormalTextRun SCXO131545408 BCX8\">How would <strong>1101.0011<\/strong> be represented in binary floating point representation using <strong>16 bits<\/strong> for the <strong>mantissa<\/strong> (including the sign bit) and<strong> 8 bits<\/strong> for the <strong>exponent<\/strong>?<\/span><\/span><span class=\"EOP SCXO131545408 BCX8\">\u00a0<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-54\" src=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16200739\/Screenshot-2022-05-16-200642-300x42.png\" alt=\"\" width=\"536\" height=\"75\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16200739\/Screenshot-2022-05-16-200642-300x42.png 300w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16200739\/Screenshot-2022-05-16-200642-768x107.png 768w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16200739\/Screenshot-2022-05-16-200642-624x87.png 624w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16200739\/Screenshot-2022-05-16-200642.png 862w\" sizes=\"auto, (max-width: 536px) 100vw, 536px\" \/><\/p>\n<p><strong><span class=\"TextRun SCXO123632459 BCX8\" lang=\"EN-GB\" xml:lang=\"EN-GB\" data-contrast=\"none\"><span class=\"NormalTextRun SCXO123632459 BCX8\">The decimal place moved 4 places to the left<\/span><\/span><\/strong><\/p>\n<p><strong>Sign would be 0<\/strong><\/p>\n<p><strong>The mantissa is then 110100111 + 000000 <\/strong>to make it up to 15 bits<\/p>\n<p>= <strong>110100111000000\u00a0<\/strong><\/p>\n<p><strong><span class=\"TextRun SCXO50625835 BCX8\" lang=\"EN-GB\" xml:lang=\"EN-GB\" data-contrast=\"none\"><span class=\"NormalTextRun SCXO50625835 BCX8\">The exponent is then 4 = 00000100 in\u00a0 binary<\/span><\/span><span class=\"EOP SCXO50625835 BCX8\">\u00a0<\/span><\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-55\" src=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16201030\/Screenshot-2022-05-16-200951-300x41.png\" alt=\"\" width=\"884\" height=\"121\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16201030\/Screenshot-2022-05-16-200951-300x41.png 300w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16201030\/Screenshot-2022-05-16-200951-1024x140.png 1024w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16201030\/Screenshot-2022-05-16-200951-768x105.png 768w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16201030\/Screenshot-2022-05-16-200951-624x86.png 624w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16201030\/Screenshot-2022-05-16-200951.png 1138w\" sizes=\"auto, (max-width: 884px) 100vw, 884px\" \/><\/p>\n<h2 style=\"color: red\"><span class=\"TextRun SCXO149968594 BCX8\" lang=\"EN-GB\" xml:lang=\"EN-GB\" data-contrast=\"none\"><span class=\"NormalTextRun SCXO149968594 BCX8\">Example 2 &#8211; Negative Exponent<\/span><\/span><\/h2>\n<p><span class=\"TextRun SCXO141853741 BCX8\" lang=\"EN-GB\" xml:lang=\"EN-GB\" data-contrast=\"none\"><span class=\"NormalTextRun SCXO141853741 BCX8\">How would <strong>0.0001001<\/strong> be represented in binary floating point representation using <strong>16 bits<\/strong> for the <strong>mantissa<\/strong> (including the sign bit) and<strong> 8 bits<\/strong> for the <strong>exponent<\/strong>?<\/span><\/span><span class=\"EOP SCXO141853741 BCX8\">\u00a0<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-56\" src=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16202044\/Screenshot-2022-05-16-202009-300x44.png\" alt=\"\" width=\"566\" height=\"83\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16202044\/Screenshot-2022-05-16-202009-300x44.png 300w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16202044\/Screenshot-2022-05-16-202009-768x114.png 768w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16202044\/Screenshot-2022-05-16-202009-624x92.png 624w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16202044\/Screenshot-2022-05-16-202009.png 866w\" sizes=\"auto, (max-width: 566px) 100vw, 566px\" \/><\/p>\n<p><strong>The decimal place moved 3 places to the right\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/strong><\/p>\n<p><strong>Sign would be 0<\/strong><\/p>\n<p><strong>The mantissa is then 1001 + 00000000000 <\/strong>to make it up to 15 bits<\/p>\n<p>= <strong>100100000000000\u00a0<\/strong><\/p>\n<p><strong><span class=\"TextRun SCXO50625835 BCX8\" lang=\"EN-GB\" xml:lang=\"EN-GB\" data-contrast=\"none\"><span class=\"NormalTextRun SCXO50625835 BCX8\">The exponent is then -3\u00a0<\/span><\/span><\/strong><\/p>\n<p><strong>00000011\u00a0<\/strong><br \/>\n<strong>11111100\u00a0<\/strong><br \/>\n<strong>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 +1\u00a0<\/strong><br \/>\n<strong>11111101 would be the exponent<\/strong><\/p>\n<p><strong><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-57\" src=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16202623\/Screenshot-2022-05-16-202024-300x39.png\" alt=\"\" width=\"787\" height=\"102\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16202623\/Screenshot-2022-05-16-202024-300x39.png 300w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16202623\/Screenshot-2022-05-16-202024-1024x132.png 1024w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16202623\/Screenshot-2022-05-16-202024-768x99.png 768w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16202623\/Screenshot-2022-05-16-202024-624x80.png 624w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16202623\/Screenshot-2022-05-16-202024.png 1132w\" sizes=\"auto, (max-width: 787px) 100vw, 787px\" \/>\u00a0<\/strong><\/p>\n<h2 style=\"color: red\"><span class=\"TextRun SCXO149968594 BCX8\" lang=\"EN-GB\" xml:lang=\"EN-GB\" data-contrast=\"none\"><span class=\"NormalTextRun SCXO149968594 BCX8\">Example 3 &#8211; Negative Mantissa<\/span><\/span><\/h2>\n<p><span class=\"TextRun SCXO69870402 BCX8\" lang=\"EN-GB\" xml:lang=\"EN-GB\" data-contrast=\"none\"><span class=\"NormalTextRun SCXO69870402 BCX8\">How would <strong>-101.00011<\/strong> be represented in binary floating point representation using <strong>16 bits<\/strong> for the <strong>mantissa<\/strong> (including the sign bit) and <strong>8 bits<\/strong> for the exponent?<\/span><\/span><span class=\"EOP SCXO69870402 BCX8\">\u00a0<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-58\" src=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16203741\/Screenshot-2022-05-16-203642-300x42.png\" alt=\"\" width=\"671\" height=\"94\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16203741\/Screenshot-2022-05-16-203642-300x42.png 300w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16203741\/Screenshot-2022-05-16-203642-768x106.png 768w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16203741\/Screenshot-2022-05-16-203642-624x86.png 624w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16203741\/Screenshot-2022-05-16-203642.png 866w\" sizes=\"auto, (max-width: 671px) 100vw, 671px\" \/><\/p>\n<p><strong>The decimal place moved 3 places to the left<\/strong><\/p>\n<p><strong>The exponent is then 3 \u00a0<\/strong><\/p>\n<p><strong>The Sign is 1 because the mantissa is negative\u00a0<\/strong><\/p>\n<p><strong>The mantissa is then <span class=\"TextRun SCXO69870402 BCX8\" lang=\"EN-GB\" xml:lang=\"EN-GB\" data-contrast=\"none\"><span class=\"NormalTextRun SCXO69870402 BCX8\">10100011 <\/span><\/span> + 0000000 <\/strong>to make it up to 15 bits<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-59\" src=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16203852\/Screenshot-2022-05-16-203658-300x40.png\" alt=\"\" width=\"660\" height=\"88\" srcset=\"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16203852\/Screenshot-2022-05-16-203658-300x40.png 300w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16203852\/Screenshot-2022-05-16-203658-1024x135.png 1024w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16203852\/Screenshot-2022-05-16-203658-768x102.png 768w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16203852\/Screenshot-2022-05-16-203658-624x83.png 624w, https:\/\/blogs.glowscotland.org.uk\/glowblogs\/public\/phshighercomputingscience\/uploads\/sites\/10042\/2022\/05\/16203852\/Screenshot-2022-05-16-203658.png 1134w\" sizes=\"auto, (max-width: 660px) 100vw, 660px\" \/><\/p>\n<h2 style=\"color: red\">Range and Accuracy<\/h2>\n<p><span data-contrast=\"none\">It is possible to improve the\u00a0<\/span><strong>accuracy<\/strong><span data-contrast=\"none\"><strong>\u00a0<\/strong>of a floating point number by\u00a0<\/span><strong>increasing<\/strong><span data-contrast=\"none\"><strong>\u00a0<\/strong>the number of bits devoted to the\u00a0<\/span><strong>mantissa<\/strong><span data-contrast=\"none\">. The\u00a0<\/span><strong>range<\/strong><span data-contrast=\"none\"><strong>\u00a0<\/strong>of numbers held can be\u00a0<\/span><strong>increased<\/strong><span data-contrast=\"none\"><strong>\u00a0<\/strong>if more bits are devoted to the storage of the\u00a0<\/span><strong>exponent<\/strong><span data-contrast=\"none\">.<\/span><\/p>\n<p><span data-contrast=\"none\">There will always be a\u00a0<\/span><span data-contrast=\"none\"><strong>trade-off between accuracy<\/strong> and range<\/span><span data-contrast=\"none\">\u00a0when using floating point notation, as there will always be a set number of bits allocated to storing real numbers, with the potential to increase or decrease the number of bits used for the mantissa against the number of bits used for the exponent.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In floating point notation, the real number is stored as 2 separate bits of data A storage location called the\u00a0mantissa\u00a0holds the complete number without the point. A storage location called the\u00a0exponent\u00a0holds the number of places that the point must be moved in the original number to place it at the left hand side. To Work [&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-53","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phshighercomputingscience\/wp-json\/wp\/v2\/pages\/53","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phshighercomputingscience\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phshighercomputingscience\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phshighercomputingscience\/wp-json\/wp\/v2\/users\/79984"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phshighercomputingscience\/wp-json\/wp\/v2\/comments?post=53"}],"version-history":[{"count":4,"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phshighercomputingscience\/wp-json\/wp\/v2\/pages\/53\/revisions"}],"predecessor-version":[{"id":64,"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phshighercomputingscience\/wp-json\/wp\/v2\/pages\/53\/revisions\/64"}],"wp:attachment":[{"href":"https:\/\/blogs.glowscotland.org.uk\/glowblogs\/phshighercomputingscience\/wp-json\/wp\/v2\/media?parent=53"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}