From 21122c7b6518879ad0057fa32ae53c341d9ebfcc Mon Sep 17 00:00:00 2001 From: miod Date: Sun, 13 Aug 2023 06:56:10 +0000 Subject: [PATCH] Make sure modff() returns correct values for infinities. Reported by Willemijn Coene. --- lib/libm/src/s_modff.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/libm/src/s_modff.c b/lib/libm/src/s_modff.c index 829bfce7c68..2a014dea8a9 100644 --- a/lib/libm/src/s_modff.c +++ b/lib/libm/src/s_modff.c @@ -45,6 +45,8 @@ modff(float x, float *iptr) } else { /* no fraction part */ u_int32_t ix; *iptr = x*one; + if (jj0 == 0x80) /* +-inf or NaN */ + return (0.0 / x); /* +-0 or NaN */ GET_FLOAT_WORD(ix,x); SET_FLOAT_WORD(x,ix&0x80000000); /* return +-0 */ return x; -- 2.20.1