math: fix cr check, stricter except check
authorSzabolcs Nagy <nsz@port70.net>
Wed, 3 Jul 2013 19:04:08 +0000 (19:04 +0000)
committerSzabolcs Nagy <nsz@port70.net>
Wed, 3 Jul 2013 19:04:08 +0000 (19:04 +0000)
src/math/Makefile
src/math/util.h

index 5d6b9df..360dc18 100644 (file)
@@ -1,5 +1,6 @@
 CFLAGS+=-g -pipe -std=c99 -D_POSIX_C_SOURCE=200809L -Wall -Wno-unused-function -Wno-missing-braces
-CFLAGS+=-Wno-unknown-pragmas -fno-builtin -frounding-math -D_GNU_SOURCE
+CFLAGS+=-Wno-unknown-pragmas -fno-builtin -frounding-math
+CFLAGS+=-D_GNU_SOURCE -O0
 LDFLAGS+=-g -lm
 
 SRC=$(sort $(wildcard *.c))
@@ -7,7 +8,7 @@ OBJ=$(SRC:.c=.o)
 BINOBJ=$(filter-out util.o,$(OBJ))
 BIN=$(BINOBJ:.o=)
 
-#include ../../config.mak
+-include ../../config.mak
 
 all: $(BIN)
 run: all
@@ -20,6 +21,7 @@ $(OBJ): util.h
 %.o: %.c
        $(CC) $(CFLAGS) -c -o $@ $<
 %: %.c
+
 %: %.o
        $(CC) $(LDFLAGS) -o $@ $^
 
index d84b0e3..9218a75 100644 (file)
@@ -101,11 +101,9 @@ float ulperrl(long double got, long double want, float dwant);
 
 static int checkexcept(int got, int want, int r)
 {
-       // TODO: we dont checkunderflow and inexact for now
        if (r == RN)
-               return (got|INEXACT|UNDERFLOW) == (want|INEXACT|UNDERFLOW);
-//             return got == want || got == (want|INEXACT);
-       return 1;
+               return got == want || got == (want|INEXACT);
+       return (got|INEXACT|UNDERFLOW) == (want|INEXACT|UNDERFLOW);
 }
 
 static int checkulp(float d, int r)
@@ -120,6 +118,6 @@ static int checkcr(long double y, long double ywant, int r)
 {
        if (isnan(ywant))
                return isnan(y);
-       return y == ywant;
+       return y == ywant && signbit(y) == signbit(ywant);
 }