diff --git a/src/math/Makefile b/src/math/Makefile index 5d6b9df..360dc18 100644 --- a/src/math/Makefile +++ b/src/math/Makefile @@ -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 $@ $^ diff --git a/src/math/util.h b/src/math/util.h index d84b0e3..9218a75 100644 --- a/src/math/util.h +++ b/src/math/util.h @@ -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); }