We all know that there are values in decimal that don't have an exact representation in binary.
For example the decimal value 0.1
.
In IEEE floating point format it can have different representations depending on how many bits you want to dedicate to representing a floating-point value.
Single Precision (32-bits)
Double Precision (64-bits)
Extended Precision (80-bits)
In other words, the decimal value 0.1
does not have an exact representation in binary, it is endlessly repeating value:
0.0 0011 0011 0011 0011 0011 0011 0011 0011 ...
0.0 ̅0̅0̅1̅1
In the same way 1⁄3 has no exact representation in decimal - its digits after "decimal point" keep repeating forever:
0.33333 33333 33333 33333 33333 33333 33333 ...
0.̅3
Are there any values in binary that don't have an exact representation in decimal?
Why am I asking? To extend the bounds of understanding, and add to the sum of human knowledge.
Edit: I don't know why someone is voting to close as a duplicate when the linked question is literally the exact opposite of mine.
No, every binary floating-point number has an exact representation in decimal.
The numbers that can be represented exactly in binary floating-point (with a finite number of bits) are precisely those rational numbers which can be written with a denominator which is a power of 2, i.e. x = a/2n for integers a and n.
The numbers that can be represented exactly in binary floating-point (with a finite number of digits) are precisely those rational numbers which can be written with a denominator which is a power of 10, i.e. y = b/10n.
But every number from the first category is also in the second category, since a/2n = a•5n/10n.
More generally, every number with an exact representation in base u will also have an exact representation in base v, if and only if every prime factor of u is also a prime factor of v. This will ensure that 1/un can be written as a/vm for some a and m.
This explains the asymmetry: 2 is prime, and the prime factors of 10 are 2 and 5. So every prime factor of 2 is a prime factor of 10, but not the other way around.