From: miod Date: Sun, 13 Aug 2023 06:56:10 +0000 (+0000) Subject: Make sure modff() returns correct values for infinities. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=21122c7b6518879ad0057fa32ae53c341d9ebfcc;p=openbsd Make sure modff() returns correct values for infinities. Reported by Willemijn Coene. --- 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;