From fd88e359bfc753c1d4f05a9073d52c9ff417ff64 Mon Sep 17 00:00:00 2001 From: Mazet Laurent Date: Sun, 1 Jan 2023 22:38:52 +0100 Subject: [PATCH] fix precision --- calc.c | 4 ++-- getcomments.pl | 0 parser.c | 2 +- parser.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) mode change 100644 => 100755 getcomments.pl diff --git a/calc.c b/calc.c index 41cc6e0..e255bd2 100644 --- a/calc.c +++ b/calc.c @@ -163,8 +163,8 @@ int main (int argc, char *argv[]) // test: echo "2 ^ 3 * 4 + 5" | calc.exe | grep -q '=> 3.7e1' // test: echo "2 + 3 * 4 ^ 5" | calc.exe | grep -q '=> 3.074e3' // test: echo "2 ^ 3 * 4 + cos(5/6)" | calc.exe | grep -q '=> 3.267241e1' -// test: echo "95-6.3*15-1" | calc.exe | grep -q '=> -5.000028e-1' -// test: echo "95 - 6.3 * 15 - 1" | calc.exe | grep -q '=> -5.000028e-1' +// test: echo "95-6.3*15-1" | calc.exe | grep -q '=> -5e-1' +// test: echo "95 - 6.3 * 15 - 1" | calc.exe | grep -q '=> -5e-1' // test: echo "95-6.3+15" | calc.exe | grep -q '=> 1.037e2' // test: echo "-cos (0) + 1" | calc.exe | grep -q '=> 0' // test: echo "quit" | calc.exe | grep -q 'bye' diff --git a/getcomments.pl b/getcomments.pl old mode 100644 new mode 100755 diff --git a/parser.c b/parser.c index 2660b43..b7b74e2 100644 --- a/parser.c +++ b/parser.c @@ -254,7 +254,7 @@ element_t *parser (char *str, char **next, int prio) (*str == '.') || (*str == '+') || (*str == '-')) { VERBOSE (DEBUG, PRINTOUT ("start processing value\n")); char *pt; - float value = strtof (str, &pt); + double value = strtod (str, &pt); VERBOSE (INFO, PRINTOUT ("Value: %f\n", value)); if (str != pt) { if (root == NULL) { diff --git a/parser.h b/parser.h index 90dba49..629b1b4 100644 --- a/parser.h +++ b/parser.h @@ -30,7 +30,7 @@ typedef struct _element_t { func_t func; int nbops; struct _element_t *ops[MAX_OPERANDS]; - float value; + double value; int prio; } element_t; -- 2.30.2