Attached is some C code that compares:
- Generates 256 random complex numbers, between +/-2^23
- FFTs using doubles
- FFTs using floats
- FFTs using fixed point (implemented using "long longs") also using scaled sine/cos values.
- Prints the results
No external libraries are used - so "gcc -o my_fft my_fft.c -lm" will work.
Input integer data ranges from -8341031 to 8386818
Transform of 256 random complex numbers
=========================================
bin ==== Doubles ========== ==== Floats =========== == err (double-float) == ====== Fixed point ==== == err (double-fixed) ==
0, (-311468.32, -113157.76), (-311468.34,-113157.78), ( 0.02, 0.02), (-311468.25,-113157.75), ( 0.07, 0.01)
1, (-450432.59, 73399.90), (-450432.56, 73399.89), ( 0.03, 0.01), (-450432.25, 73399.75), ( 0.34, 0.15)
2, ( 67731.35, -153482.60), ( 67731.34,-153482.58), ( 0.01, 0.03), ( 67731.25,-153482.50), ( 0.10, 0.10)
3, ( 217357.98, 225662.18), ( 217357.98, 225662.14), ( 0.01, 0.04), ( 217357.75, 225661.75), ( 0.23, 0.43)
4, ( 83580.10, 536216.31), ( 83580.08, 536216.31), ( 0.03, 0.00), ( 83580.00, 536216.00), ( 0.10, 0.31)
5, ( 28770.92, -132197.57), ( 28770.92,-132197.56), ( 0.00, 0.01), ( 28770.75,-132197.50), ( 0.17, 0.07)
...
You can play with scaling factors on the double => fixed point conversion, as well has the scaling factor used in the sine / cosine table, and see what effects it has on the errors.