fix fesetround error checking

Submitted by Szabolcs Nagy on Sept. 26, 2018, 9:18 p.m.

Details

Message ID 20180926211840.GI10209@port70.net
State New
Series "fix fesetround error checking"
Headers show

Commit Message

Szabolcs Nagy Sept. 26, 2018, 9:18 p.m.
simple fix, not sure why this was wrong.

Patch hide | download patch | download mbox

From b9200510d08fa1b6aba8d1ee4ffbdf8892397cfa Mon Sep 17 00:00:00 2001
From: Szabolcs Nagy <nsz@port70.net>
Date: Mon, 10 Sep 2018 19:06:21 +0000
Subject: [PATCH] fix fesetround error checking

Rounding modes are not bit flags, but arbitrary non-negative integers.
---
 src/fenv/fesetround.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/fenv/fesetround.c b/src/fenv/fesetround.c
index 50e58f11..4e2f164d 100644
--- a/src/fenv/fesetround.c
+++ b/src/fenv/fesetround.c
@@ -7,18 +7,17 @@  hidden int __fesetround(int);
 
 int fesetround(int r)
 {
-	if (r & ~(
-		FE_TONEAREST
+	if (r != FE_TONEAREST
 #ifdef FE_DOWNWARD
-		|FE_DOWNWARD
+		&& r != FE_DOWNWARD
 #endif
 #ifdef FE_UPWARD
-		|FE_UPWARD
+		&& r != FE_UPWARD
 #endif
 #ifdef FE_TOWARDZERO
-		|FE_TOWARDZERO
+		&& r != FE_TOWARDZERO
 #endif
-		))
+	)
 		return -1;
 	return __fesetround(r);
 }
-- 
2.18.0