16-bit math look-up tables – the unexpected power of scaled-integer math
1–10 of 54 posts
Re: 16-bit math look-up tables – the unexpected power of scaled-integer math
#2Re: 16-bit math look-up tables – the unexpected power of scaled-integer math
#3Cute. However, unless you're using a CPU from the 6502 era, it's probably not worth the trouble for multiplication and division. Today's low-end CPUs have good multiply hardware, and for a few dollars more, you get a decent FPU. Trig functions, though, may be worth precomputing. The standard libraries for trig functions often grind their way out to far more precision than you need for graphics or control, and that ta…
Re: 16-bit math look-up tables – the unexpected power of scaled-integer math
#4Cute. However, unless you're using a CPU from the 6502 era, it's probably not worth the trouble for multiplication and division. Today's low-end CPUs have good multiply hardware, and for a few dollars more, you get a decent FPU. Trig functions, though, may be worth precomputing. The standard libraries for trig functions often grind their way out to far more precision than you need for graphics or control, and that ta…
Except for the cache hit.
Re: 16-bit math look-up tables – the unexpected power of scaled-integer math
#5Earlier quoted context omitted.
Except for the cache hit.
If you're interpolating and only need 16 bits of precision, you need only a small table. 32 or 64 entries should be enough for sine and cosine.
When I first wrote that code, I was targeting 32 bit ARM, with possibly very weak floating point units. These days, on the types of chips you'd see in phones (or computers in the $9-$40 range like rpi 3), the floating point calculation is _so_ fast (especially with simd) that the cost of the memory lookup starts dominating. So, the NEON implementation computes 4 sin values in a gulp, using a floating point polynomial approximation about the same precision as above[1].
[0] https://github.com/google/music-synthesizer-for-android/blob...
[1] https://github.com/google/music-synthesizer-for-android/blob...
Re: 16-bit math look-up tables – the unexpected power of scaled-integer math
#6Re: 16-bit math look-up tables – the unexpected power of scaled-integer math
#7http://www.johngustafson.net/presentations/Unums2.0.pptx
http://www.johngustafson.net/presentations/Unums2.0.pdf
Re: 16-bit math look-up tables – the unexpected power of scaled-integer math
#8Fractint[1], the site has a certificate error, but otherwise works fine, even the software still gets updated from time to time.
Re: 16-bit math look-up tables – the unexpected power of scaled-integer math
#9Back in the day of 80286's and 80386's there was a popular Fractal generating software that did all calculations in fixed point arithmetic because PCs usually had no FPU back then. Fractint[1], the site has a certificate error, but otherwise works fine, even the software still gets updated from time to time. [1] https://fractint.org/
Re: 16-bit math look-up tables – the unexpected power of scaled-integer math
#10Cute. However, unless you're using a CPU from the 6502 era, it's probably not worth the trouble for multiplication and division. Today's low-end CPUs have good multiply hardware, and for a few dollars more, you get a decent FPU. Trig functions, though, may be worth precomputing. The standard libraries for trig functions often grind their way out to far more precision than you need for graphics or control, and that ta…
When we talk PC, fixed point math was popular a few generations longer than the 6502 era. The 6502 had no multiply and division instructions at all, and up to the 80386 there was only integer multiply and division and that was slow as molasses. Before the 80486 fixed point wasn't a matter of speed, it was a matter of survival (at least for graphics and such).