From 4bd705cf33bf71fa578b98f175c2e307caa33a84 Mon Sep 17 00:00:00 2001 From: Markus Hoffmann Date: Mon, 26 Aug 2019 07:58:25 +0200 Subject: [PATCH] Bugfix: gitlab issue #2: SGN(0) returned 1 --- src/defs.h | 1 - src/functions.c | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/defs.h b/src/defs.h index a07e290..a702f0b 100644 --- a/src/defs.h +++ b/src/defs.h @@ -56,7 +56,6 @@ #endif #define min(a,b) ((ab)?a:b) -#define sgn(x) ((x<0)?-1:1) #define rad(x) (PI*x/180) #define deg(x) (180*x/PI) #ifndef LOBYTE diff --git a/src/functions.c b/src/functions.c index 2cc6e56..aaea6c8 100644 --- a/src/functions.c +++ b/src/functions.c @@ -787,7 +787,11 @@ static int f_realloc(int adr,int size) {return(POINTER2INT(realloc((char *)IN static double f_rnd(double d) {return((double)rand()/((double)RAND_MAX+1));} static int f_size(STRING n) {return(stat_size(n.pointer)); } -static int f_sgn(double b) {return(sgn(b));} +static int f_sgn(double b) { + if(b>0.0) return 1; + if(b<0.0) return -1; + return 0; +} static int f_srand(double d) {srand((int)d);return(0);} static int f_succ(double b) {return((int)(b+1));}