# Why does this whole number have a recurring value? [duplicate]

I have a math question which that may seem simple to some but not to me if you where to do the calculation 12.30 * 12 it would equal 147.60 but why is that when I show the answer to more then two decimal place it has a 2 at the end 147.60000000000002 where did the 2 come from if 12.30 is a whole number ?

Again Im sorry if this sounds dumb but Im curious and thought this is the best place to ask.

• It looks like it is an artifact of how numbers are represented in binary internally. Sep 6 '16 at 13:20
• Rationalize[12.30]*12 Sep 6 '16 at 13:28

It's a numerical artifact that is due to finite precision of computer calculations. Indeed, when one computes

SetAccuracy[12.30*12, 15]


147.60000000000002

It's notable that the input is in decimal system (at least the user thinks of it as such), but the computer uses its binary representation. For example, $\frac{1}{10}$ is an exact number, but 0.1 has an infinite expansion when expressed in binary (i.e., $0.1_{10}=0.000110011001100110011001100110011..._2$; see also here). Hence the computer never uses exactly $\frac{1}{10}$ but a rounded number:

SetAccuracy[0.1, 20]


0.1000000000000000056

What you see above in the case of 12.30*12 is most likely a result of such rounding. It should be also noted that in most published materials, when some result is given to e.g. 20 decimal digits, in most cases it is not reasonable: in fact, every machine will give a slightly different output. The computation on two different computers (or different software) can give results different on the 15th or 12th or some other decimal place.

• Thank you for this makes a lot of sense Sep 6 '16 at 14:40
{"ft_lang_label":"__label__en","ft_lang_prob":0.9039496,"math_prob":0.97544837,"size":1066,"snap":"2021-43-2021-49","text_gpt3_token_len":282,"char_repetition_ratio":0.13653484,"word_repetition_ratio":0.0,"special_character_ratio":0.32739213,"punctuation_ratio":0.15981735,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9945156,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-11-27T08:23:30Z\",\"WARC-Record-ID\":\"<urn:uuid:a7727cc9-e4cc-4ed0-b747-525b70740a9c>\",\"Content-Length\":\"124566\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:163cd1f3-9f47-4bca-9722-c09ab2364f3c>\",\"WARC-Concurrent-To\":\"<urn:uuid:a5d990df-965c-4bf2-ad0e-98525ef0c8ba>\",\"WARC-IP-Address\":\"151.101.65.69\",\"WARC-Target-URI\":\"https://mathematica.stackexchange.com/questions/125693/why-does-this-whole-number-have-a-recurring-value?noredirect=1\",\"WARC-Payload-Digest\":\"sha1:JI73OILNYSTCWBI4IUBN7XV65B5ATEPH\",\"WARC-Block-Digest\":\"sha1:2HUGU3LNQIMS6DWGWUCBCSCOZIHHHRJ3\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-49/CC-MAIN-2021-49_segments_1637964358153.33_warc_CC-MAIN-20211127073536-20211127103536-00632.warc.gz\"}"}