From 4b349c184c640d206db6b71680b02c83993df8de Mon Sep 17 00:00:00 2001 From: Michael Nolan Date: Tue, 14 Apr 2020 09:46:23 -0400 Subject: [PATCH] Add experiment testing the effects of adding extra bits to cordic --- src/ieee754/cordic/test/test_software.py | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/ieee754/cordic/test/test_software.py diff --git a/src/ieee754/cordic/test/test_software.py b/src/ieee754/cordic/test/test_software.py new file mode 100644 index 00000000..d48eefb1 --- /dev/null +++ b/src/ieee754/cordic/test/test_software.py @@ -0,0 +1,31 @@ +import math +import unittest +from python_sin_cos import run_cordic +import random + +class SoftwareTestCase(unittest.TestCase): + def test_extrabits(self): + fracbits = 16 + extrabits = 18 + M = (1 << fracbits) + print(M) + for i in range(200000): + f = random.uniform(-math.pi/2, math.pi/2) + i = int(round(f * M)) + f = i/M + print(f"int: {i}, float:{f}") + i = i * (1<