News for hackers. Stuff that matters.
Re:Beware of Fast-Math by pie_flavor on Saturday May 31, 2025 @12:00PM (#44145129)
One of the things I always appreciate about the crypto community is that you do not have to ask what numeric type is being used for money, it is always 8-digit fixed-point. No floating-point rounding errors to be found anywhere.
Re:Beware of Fast-Math by immibis on Saturday May 31, 2025 @12:02PM (#44145147)
Correction: Bitcoin is 8-digit fixed-point. But Lightning is 10, IIRC. Other currencies have different conventions. Still, it's fixed within a given system and always fixed-point. As far as I'm aware, there are no floating-point cryptocurrencies at all, because it would be an obvious exploit vector - keep withdrawing 0.000000001 units from your account that has 1.0 units.
Re:Beware of Fast-Math by Athas on Saturday May 31, 2025 @01:32PM (#44145769)
How does this avoid rounding error? Division and multiplication and still result in nonrepresentable numbers, right?
Re:Beware of Fast-Math by pie_flavor on Sunday June 01, 2025 @01:23PM (#44152411)
It is not hard to remember what int division is about, when your types are ints in code. It also comes up almost never, and isn't what floating-point rounding error means. You aren't multiplying money 99% of the time, and when you are, you don't care about exacting precision (e.g. 20% discount). Floating-point rounding error, on the other hand, is about how 0.1 + 0.2 != 0.3.