2 ms·
> offset by some decimal fraction so that about half the bits were right of decimal point. Seems weird not to use binary fixpoints. Can't really see the point
by microcolonel 9y ago
> offset by some decimal fraction so that about half the bits were right of decimal point.
Seems weird not to use binary fixpoints. Can't really see the point of using a decimal point instead of a binary point/radix.
- vidarh 9y agoPrecision / rounding requirements is often the reason for this. E.g. last time I implemented VAT rounding on a billing system (no I'm not suggesting I'd use trig functions for that; it's just an example of why precision matters) our financial controller was hovering over me with a copy of the HMRC rules for VAT rounding, and while we certainly could do it with floats or binary fixed point if we took some care, doing it with decimal fixed points made it a lot easier to demonstrate to our financial controller that I wasn't doing anything that'd make him liable for tax evasion. Different representations works best for different things, but you better understand the tradeoffs.
- sehugg 9y agoI think they're talking about an implied decimal point, i.e. fixed point math.
- vidarh 9y agoYes, but the question is in part why use an implied decimal point instead of an implied binary point. You can do fixed binary point just by treating everything past a given bit as the fraction - it's simpler. The main reason would be differences in expected precision/rounding behavior depending on how many bits you use past the binary/decimal point. E.g. if you use 4 bits past the point, you can represent 1/10's in decimal but 1/16's in binary. But while the binary representation offers more precision, it allows you to represent different values. If you e.g. want to represent 0.2, a single decimal represented in 4 bits will allow you to do that, but with 4 bits past a binary decimal point means you'll need to round down to 0.1875 (3/16) or up to 0.25 (4/16).
- valarauca1 9y agoif your dealing with currencies you can’t use fractions. Unrepresentative decimal values (.33, .34, .66) are non trivial without many bits of fraction space. Your IEEE standard for floating points has a lot of complex rules and standard binary layouts to ensure these values are represented. You end up needing a lot more space and rules than just diving by 10^3
- vidarh 9y agoOf course you can use fractions. You can't reasonably use binary fractions. But the discussion is about fixed point representations, not floating point anyway.
- DannyB2 9y agoI should have said binary point.