Make sure modff() returns correct values for infinities.
authormiod <miod@openbsd.org>
Sun, 13 Aug 2023 06:56:10 +0000 (06:56 +0000)
committermiod <miod@openbsd.org>
Sun, 13 Aug 2023 06:56:10 +0000 (06:56 +0000)
Reported by Willemijn Coene.

lib/libm/src/s_modff.c

index 829bfce..2a014de 100644 (file)
@@ -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;