|
|
|
|
|
by dragonwriter
1724 days ago
|
|
> How are rationals used to represent decimals? Decimals are just the subset of rationals where the denominator is always a power of 10, so the representation and arithmetic operations are simple if you already have rational support (though if you need to preserve decimal results, you need approximation logic for division, since dividing two rationals with denominators that are powers of 10 may result in a rational with a denominator that is not a power of 10.) |
|
This is also true for adding, subtracting, and multiplying, though in those cases it is always trivial to convert the result into a form where the denominator is a power of 10.