4 ms·
It's very rare not to need GCD reduction, though; multiplying values burns through bits extremely fast. Only doing factor-2 reduction isn't infeasible but you'd
by Veedrac 8y ago
It's very rare not to need GCD reduction, though; multiplying values burns through bits extremely fast. Only doing factor-2 reduction isn't infeasible but you'd be further damaging an already iffy type.
- tomxor 8y ago> It's very rare not to need GCD reduction, though Yes good point, I did wonder this... it's easy to look at the individual operations and think "that's cheap" but holistically, the GCD which I assume is expensive could make the overall performance benefits moot. It might be optimisable to not do it unnecessarily after _every_ operation though? Perhaps then the only advantage in terms of hardware use is that it can be implemented on a CPU with only ints e.g small micro-controllers with no FPU or int divide. I think that by comparison implementing a soft FPU would be impractical, still niche I guess.
- Veedrac 8y agoI'm not sure, but I suspect your best alternative to 32-bit floats/floating-bar-rationals or 64-bit rationals when you have no FPU is a 64-bit fixed-point value with compressed floating-point representations if you need to store it compactly in memory.