From db4b6cef06a63b1a43c654c3b98fe4e47fc7d411 Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Wed, 3 Jul 2013 19:04:08 +0000 Subject: [PATCH 1/1] math: fix cr check, stricter except check --- src/math/Makefile | 6 ++++-- src/math/util.h | 8 +++----- 2 files changed, 7 insertions(+), 7 deletions(-) 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); } -- 2.20.1