3 ms·
That's exactly what the other commenters are arguing about. Why should 14.7 be not representable exactly when 15 is. With python you can use Fraction(147, 10) o
by vhcr 3y ago
That's exactly what the other commenters are arguing about. Why should 14.7 be not representable exactly when 15 is. With python you can use Fraction(147, 10) or Decimal("14.7"), but you have to explicitly opt-in.
- taeric 3y agoBut, go further. Why shouldn't 1/3 be represented exactly when 1/5 is? If it makes you feel better, with our current system, 1/256 is represented exactly. Using relatively few bits, all told. :D
- nyrikki 3y agoFractions, or the rationals are equivalent to polynomials. The rationals are also in aleph-naught, and thus have a one to one and onto mapping to the natural numbers. Floating point numbers are equivalent to rationals with their base as the denominator I. base-2 rationals with denominators that are powers of 2 will have termination expansions. Useful for storage but not arithmetic as Fraction(147/10) has 10 in the denominator and 5 is a prime factor that isn't in the base. BPD, or Binary Packed Decimal also allows for the storage of 14.7 But once again not useful for arithmetic. Accumulated errors, catastrophic cancelation, etc are real problems too. In decimal, 1/3 can be stored exactly but the expansion is 3 33333... Because 3 is prime and not a prime factor of 10. Had we decided on something rather than 10 for our base it may have worked out for computers better, but it is what it is. The rationals are nice, being the only countable, totally ordered sets. But producing a computer circuit that can perform arithmetic on them isn't practical as far as I know without using fixed radix and the associated problems with non-terminating expansions.