Page 2 of 2
Use fast trig in C on the X16
Posted: Sun Mar 28, 2021 3:59 pm
by SlithyMatt
1 hour ago, Michael Parson said:
It seems to be due to how the 6502 does floating point vs the 'traditional' C implementation using IEEE 754.
In short, the 6502 doesn't do floating point at all. You need to implement it with 8-bit integer math. That's what BASIC does. You could absolutely implement IEEE 754 as a cc65 library, it's just going to be very slow same as any FP implementation.
Use fast trig in C on the X16
Posted: Sun Mar 28, 2021 7:30 pm
by paulscottrobson
On 3/26/2021 at 5:22 PM, x16tial said:
How do BASICs trig functions work? Tables of information might already be in ROM.
Basic Trigs, Logs, Exponents and most of those similar functions, and powers, are Taylor Series (not sure about Square Root) which approximate to those values. The BASIC has very little other than a table of the appropriate constants.
You'd be far better off using fixed point arithmetic (say x 256) and a table. You only need degrees 0-45, everything else you can derive easily enough.
Use fast trig in C on the X16
Posted: Mon Aug 30, 2021 7:56 pm
by Edmond D
On 3/26/2021 at 10:32 AM, rje said:
SIN calls POLY1, which calls MLTPLY ($BA59), and consequently the multiply bug affects its results.
The multiply bug looks to be addressed according to the sample program listed at
https://www.c64-wiki.com/wiki/Multiply_bug