cbrt: make it friendly with non 64bit capable
authorAlan Cox <alan@linux.intel.com>
Mon, 5 Mar 2018 20:26:05 +0000 (20:26 +0000)
committerAlan Cox <alan@linux.intel.com>
Mon, 5 Mar 2018 20:26:05 +0000 (20:26 +0000)
Library/libs/cbrt.c

index 3a310f3..353cb4e 100644 (file)
@@ -93,7 +93,14 @@ double cbrt(double x)
         * before the final error is larger than 0.667 ulps.
         */
        u.value = t;
+#ifdef NO_64BIT
+       if (u.bits[LOBIT] & 0x80000000UL)
+               u.bits[HIBIT]++;
+       u.bits[LOBIT] ^= 0x80000000UL;
+       u.bits[LOBIT] &= 0xC0000000UL;
+#else
        u.bits = (u.bits + 0x80000000) & 0xffffffffc0000000ULL;
+#endif
        t = u.value;
 
        /* one step Newton iteration to 53 bits with error < 0.667 ulps */