[PATCH 1/2] RISC-V: NaN should return 0 for finite[f]

Kito Cheng <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
---
 newlib/libm/machine/riscv/s_finite.c  | 2 +-
 newlib/libm/machine/riscv/sf_finite.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/newlib/libm/machine/riscv/s_finite.c b/newlib/libm/machine/riscv/s_finite.c
index f5336e5dc..1f1f2244d 100644
--- a/newlib/libm/machine/riscv/s_finite.c
+++ b/newlib/libm/machine/riscv/s_finite.c
@@ -44,7 +44,7 @@
 int finite(double x)
 {
 	long fclass = _fclass_d (x);
-	return (fclass & FCLASS_INF) == 0;
+	return (fclass & (FCLASS_INF | FCLASS_NAN)) == 0;
 }
 #else
 #include "../../common/s_finite.c"
diff --git a/newlib/libm/machine/riscv/sf_finite.c b/newlib/libm/machine/riscv/sf_finite.c
index f1cf5c6ce..a17b0fa36 100644
--- a/newlib/libm/machine/riscv/sf_finite.c
+++ b/newlib/libm/machine/riscv/sf_finite.c
@@ -41,7 +41,7 @@
 int finitef(float x)
 {
 	long fclass = _fclass_f (x);
-	return (fclass & FCLASS_INF) == 0;
+	return (fclass & (FCLASS_INF | FCLASS_NAN)) == 0;
 }
 #else
 #include "../../common/sf_finite.c"
-- 
2.28.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.