7 ms·
If we're on embedded hardware, or can't use floats for some reason, we use 22/7. It's called fixed point arithmetic. Most CPUs have an integer instruction tha
by tailrecursion 14y ago
If we're on embedded hardware, or can't use floats for some reason, we use 22/7. It's called fixed point arithmetic. Most CPUs have an integer instruction that multiplies into a double-precision integer result, and an instruction that takes a double-precision integer dividend.
So to scale by pi, we multiply by 355, then divide by 113.
- a1k0n 14y agoIs that any better than just multiplying by pi * 2^n and then shifting right by n?