3 ms·
I don't see big benefits for the 'exact' bit. There's only a fixed (in theory, countably infinite and infinitely dense) set of numbers that can be represented e
by Someone 11y ago
I don't see big benefits for the 'exact' bit. There's only a fixed (in theory, countably infinite and infinitely dense) set of numbers that can be represented exactly. If you want to go for such a set of exactly-representable numbers, wouldn't the rationals be the better choice? That allows you, for example, to do dollar accounting in exact arithmetic.
Also, to enable round-tripping with string representations, your printf/scanf pair has to discriminate between exact and inexact versions of, for example, 3/4. If you don't, every string you read in (e.g. from XML (including reading modern spreadsheet data), json, or from user input, will have to have the 'exact' bit cleared. I guess so many numbers will be inexact that it turns out to have close to zero information content (in other words: adding it to your numbers is a waste of space)
- Maken 11y agoIt avoids error whenever possible. For example, if you are working with pure fractions the result will be exactly representable and you'll end with 1/3 + 1/3 + 1/3 = 1 instead of some approximation.
- Someone 11y agoThat would be nice, but 1/3 isn't exactly representable in this representation. Or are you suggesting that, when computing 1/3, this number format picks the best representation for a given number of bits, keeping the 'exact' bit, for 1/3, and then magically decides that, say, 85/256 and 'exact' must be 1/3, and not 85/256, or whatever other expression that could be computed exactly gets close to it?