Anon10/02/25, 22:35No.2948432
This was way more difficult than I thought, but after spending quite some time researching and modeling things in Desmos, I managed to implement all the math functions I needed. They should be quite fast, possibly faster than polyfilled float math, and precision is acceptable. The pic related shows the error(in multiplies of machine epsilon, 1/2^16). However this is not comparison to exact values but to what pico8 uses. My algorithms are actually more precise, but based on values pico8 returns I suspect they use lookup tables for trigonometry and possibly exp/ln that might be used for computing exponentiation. That's where this fuzz comes from, especially in sin/cos. They do not interpolate the values from these tables, just pick one the nearest.
Later I might try different methods, including lookup tables and benchmark them. But having 100% precise math emulation is not important right now, or ever really. It can be done later.