{"id":27,"date":"2004-08-12T23:03:13","date_gmt":"2004-08-13T07:03:13","guid":{"rendered":""},"modified":"2016-05-25T23:34:40","modified_gmt":"2016-05-26T06:34:40","slug":"apple-calculator","status":"publish","type":"post","link":"https:\/\/mikeindustries.com\/blog\/archive\/2004\/08\/apple-calculator","title":{"rendered":"Apple Flunks First Grade Math"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"\/blog\/images\/inline\/calculator.jpg\" width=\"150\" height=\"183\" border=\"0\" alt=\"\" class=\"rightinline\" \/>Something happened today which shook the very foundations of what I&#8217;ve always believed about computers.  See, maybe this was just a crazy notion, but I was always under the impression that if there was ONE thing computers did well, it was math.  Simple math, algebra, geometry, calculus&#8230; it didn&#8217;t matter.  Computers have always been equation solving machines.  Or so I thought.<\/p>\n<p>As it so happened, I was catching up on three months of procrastinated Quicken transactions and I had a slight discrepancy in my numbers.  I typed in Command-Space &#8220;cal&#8221; to launch the built-in Apple calculator via <a href=\"http:\/\/www.obdev.at\/products\/launchbar\/index4.html\" target=\"_blank\">LaunchBar<\/a> in order to check my figures.  Here is the equation I typed in:<\/p>\n<p><code>9533.24-215.10<\/code><\/p>\n<p>&#8230; and here is the garbage Apple babbled back at me: <code>9318.139999999999<\/code><\/p>\n<p>What?  How is that possible?  I&#8217;m subtracting two decimal numbers and the result is a repeating decimal?  Thinking something was wrong, I began experimenting by simplifying the equation:<\/p>\n<p><code>9533.24-.1<\/code><\/p>\n<p>Result: <code>9533.139999999999<\/code><\/p>\n<p>Convinced I had the calculator in some <a href=\"http:\/\/www.calculator.org\/rpn.html\" target=\"_blank\">whacked-out Reverse Polish mode<\/a> or something, I began checking the menus. The only relevant menu item was a setting called &#8220;Precision&#8221; which went from 0 to 16 and was defaulted at 12.  How about Precision &#8220;Infinity&#8221;?  I want my damned calculator to be precise enough to subtract simple decimals and apparently 12 isn&#8217;t enough to do this.  As it turns out, &#8220;Precision&#8221; is a bit of a misnomer for this setting because it just represents how many decimals you want to see before the number gets rounded.  Anyway, that still doesn&#8217;t explain why an equation which needs no rounding to begin with is giving me a repeating decimal.<\/p>\n<p>Upon more experimentation, I discovered the following:<\/p>\n<ol>\n<li>The error doesn&#8217;t seem occur on numbers less than 1000.<\/li>\n<li>The error only occurs on some numbers greater than 1000.<\/li>\n<li>The error doesn&#8217;t seem to occur on addition, but only subtraction.<\/li>\n<li>The principal software engineer at my company couldn&#8217;t tell me how this was even possible.<\/li>\n<\/ol>\n<p>And so there you have it&#8230; what was once simple is now apparently difficult again, thanks to the otherwise brilliant piece of engineering that is OS X Panther.  I&#8217;m sure the explanation has something to do with floating-point calculations, whatever the hell those are, but that doesn&#8217;t make this bug the least bit more acceptable.  My worst nightmare is that the repeating decimal answer actually <strong><em>is<\/em><\/strong> the correct answer from a computing standpoint but most computers are smart enough to round it for us, knowing what we really want. That would really alter my perceptions of low-level computing quite a bit.<\/p>\n<p>On the bright side, we finally found something PCs are better than Macs at.<\/p>\n<p>Subtraction.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Something happened today which shook the very foundations of what I&#8217;ve always believed about computers.  See, maybe this was just a crazy notion, but I was always under the impression that if there was ONE thing computers did well, it was math.  Simple math, algebra, geometry, calculus&#8230; it didn&#8217;t matter.  Computers have always been equation solving machines.  Or so I thought&#8230;<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38,282],"tags":[],"class_list":["post-27","post","type-post","status-publish","format-standard","hentry","category-humor","category-original"],"_links":{"self":[{"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/posts\/27","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/comments?post=27"}],"version-history":[{"count":0,"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/posts\/27\/revisions"}],"wp:attachment":[{"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/media?parent=27"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/categories?post=27"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mikeindustries.com\/blog\/wp-json\/wp\/v2\/tags?post=27"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}