summaryrefslogtreecommitdiff
path: root/cosine.c
diff options
context:
space:
mode:
authorBenjamin Chausse <benjamin@chausse.xyz>2022-09-29 16:42:58 -0400
committerBenjamin Chausse <benjamin@chausse.xyz>2022-09-29 16:42:58 -0400
commiteae5d5b8d55f5da69eea990e68497dbc0e74c9f3 (patch)
tree4dc2346c652db653320e27054a69c3aa8aa790af /cosine.c
parente8364e95ee1b38e49af29a2aa1338b3d978411f0 (diff)
Fix sine and cosine by increasing presicion
Diffstat (limited to 'cosine.c')
-rw-r--r--cosine.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/cosine.c b/cosine.c
index 58bd189..934ca3b 100644
--- a/cosine.c
+++ b/cosine.c
@@ -11,10 +11,10 @@
#include "format.h"
#include "testData.h"
-float cos(float input, int precision){
- float ttl = 1;
+double cos(double input, int precision){
+ double ttl = 1;
int denom = 1;
- float num;
+ double num;
for (int i=2;i<=(2*precision);i+=2){
num = mpow(input,i);
denom *= i*(i-1);
@@ -25,8 +25,8 @@ float cos(float input, int precision){
}
int main(){
- const int precision = 16;
- const float threshold = 1e-4;
+ const int precision = 20;
+ const double threshold = 1e-4;
for (int i=0; i<COUNT_OF(piValues);i++){
if ( abs(piValues[i][2]-cos(piValues[i][0],precision))>threshold ){