system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5 how does a calculators arithmetic differentiate from a computers.

I saw a video by fireship on youtube where in he shows if you perform the calculation 0.1 + 0.2 on computer, the output will be 0.300000000000004. if you try the same in a calculator the output is 0.3 they both use base-2 arithmetic which is binary so why is the output different? Im curious as to why this happens.
gpt
The other answers all seem to be focusing on explaining to you how computers (and calculators, too) represent numbers internally in binary all while ignoring your actual question, which is why the two get different answers even though internally they presumably do mathematics the same way.

The short answer is that most computer languages (and thus most computer programs) use the IEEE-754 floating point standard to represent fractional numbers, and numbers in IEEE-754 are represented as `a * 2^b`.  0.1 cannot be represented this way since the denominator, 10, is not a power of 2.  The more precision you get, the closer the value will be, but it will never actually be 0.1, it's always 0.999999something or 1.00000000something.  These values will be rounded according to some rules when they run on too long, so 0.1 displays as expected, but errors increase in magnitude when compounded as happens when you start doing arithmetic on the inexact values.

Calculators on the other hand typically use BCD (binary coded decimal) to represent fractional numbers.  In BCD, each *digit* is represented on it's own, and on a modern system with 8bit (or larger) bytes, this means numbers up to some maximum length can be represented precisely even if they can't be expressed as a power of two or any other number.  The downside of BCD is that it's inefficient.  An 8bit value can represent one of 256 different numbers, so using it to store the value of a number that can only range from 0-9 is extremely wasteful of space.  One way this is addressed is with "packed BCD" which will use half of the byte, or 4 bits, to hold the value for a single digit.  Since 4 bits can still hold 16 different values, the range 0-9 is still covered, but you can fit 2 digits instead of just 1 in your 8 bit value.

Hope this was understandable!