double __x2y2m1 (double x, double y) { double vals[4]; SET_RESTORE_ROUND (FE_TONEAREST); mul_split (&vals[1], &vals[0], x, x); mul_split (&vals[3], &vals[2], y, y); if (x >= 0.75) vals[1] -= 1.0; else { vals[1] -= 0.5; vals[3] -= 0.5; } qsort (vals, 4, sizeof (double), compare); /* Add up the values so that each element of VALS has absolute value at most equal to the last set bit of the next nonzero element. */ for (size_t i = 0; i <= 2; i++) { add_split (&vals[i + 1], &vals[i], vals[i + 1], vals[i]); qsort (vals + i + 1, 3 - i, sizeof (double), compare); } /* Now any error from this addition will be small. */ return vals[3] + vals[2] + vals[1] + vals[0]; }
char *replace_variable(char *line, t_shell *sh) { char *name; char *value; char **tmp; int i; int len; line = is_tild(line, sh); if (ft_strchr(line, '$') == NULL) return (line); i = 0; tmp = sort_split(add_split(sh->env, sh->local)); while (tmp[i]) { len = 0; while (tmp[i][len] != '=') len++; name = ft_strf("$%.*s", len, tmp[i]); value = &tmp[i][len + 1]; line = replace_out(line, name, value, "'"); ft_strdel(&name); i++; } ft_memdel((void**)&tmp); return (line); }
long double __x2y2m1l (long double x, long double y) { double vals[12]; SET_RESTORE_ROUND (FE_TONEAREST); union ibm_extended_long_double xu, yu; xu.d = x; yu.d = y; if (fabs (xu.dd[1]) < 0x1p-500) xu.dd[1] = 0.0; if (fabs (yu.dd[1]) < 0x1p-500) yu.dd[1] = 0.0; mul_split (&vals[1], &vals[0], xu.dd[0], xu.dd[0]); mul_split (&vals[3], &vals[2], xu.dd[0], xu.dd[1]); vals[2] *= 2.0; vals[3] *= 2.0; mul_split (&vals[5], &vals[4], xu.dd[1], xu.dd[1]); mul_split (&vals[7], &vals[6], yu.dd[0], yu.dd[0]); mul_split (&vals[9], &vals[8], yu.dd[0], yu.dd[1]); vals[8] *= 2.0; vals[9] *= 2.0; mul_split (&vals[11], &vals[10], yu.dd[1], yu.dd[1]); if (xu.dd[0] >= 0.75) vals[1] -= 1.0; else { vals[1] -= 0.5; vals[7] -= 0.5; } qsort (vals, 12, sizeof (double), compare); /* Add up the values so that each element of VALS has absolute value at most equal to the last set bit of the next nonzero element. */ for (size_t i = 0; i <= 10; i++) { add_split (&vals[i + 1], &vals[i], vals[i + 1], vals[i]); qsort (vals + i + 1, 11 - i, sizeof (double), compare); } /* Now any error from this addition will be small. */ long double retval = (long double) vals[11]; for (size_t i = 10; i != (size_t) -1; i--) retval += (long double) vals[i]; return retval; }
long double __x2y2m1l (long double x, long double y) { long double vals[5]; SET_RESTORE_ROUNDL (FE_TONEAREST); mul_split (&vals[1], &vals[0], x, x); mul_split (&vals[3], &vals[2], y, y); vals[4] = -1.0L; qsort (vals, 5, sizeof (long double), compare); /* Add up the values so that each element of VALS has absolute value at most equal to the last set bit of the next nonzero element. */ for (size_t i = 0; i <= 3; i++) { add_split (&vals[i + 1], &vals[i], vals[i + 1], vals[i]); qsort (vals + i + 1, 4 - i, sizeof (long double), compare); } /* Now any error from this addition will be small. */ return vals[4] + vals[3] + vals[2] + vals[1] + vals[0]; }