int main(int argc, char *argv[]) { printf("Testing Int : %ld\n", mul_int(1, 2)); printf("Testing Double : %ld\n", mul_double(1, 2)); return 0; }
double __muldf3(double a, double b) { double_t da; double_t db; double_t res; da.val = a; db.val = b; res.data = mul_double(da.data, db.data); return res.val; }
static tree tree_fold_binomial (tree type, tree n, unsigned int k) { unsigned HOST_WIDE_INT lidx, lnum, ldenom, lres, ldum; HOST_WIDE_INT hidx, hnum, hdenom, hres, hdum; unsigned int i; tree res; /* Handle the most frequent cases. */ if (k == 0) return build_int_cst (type, 1); if (k == 1) return fold_convert (type, n); /* Check that k <= n. */ if (TREE_INT_CST_HIGH (n) == 0 && TREE_INT_CST_LOW (n) < k) return NULL_TREE; /* Numerator = n. */ lnum = TREE_INT_CST_LOW (n); hnum = TREE_INT_CST_HIGH (n); /* Denominator = 2. */ ldenom = 2; hdenom = 0; /* Index = Numerator-1. */ if (lnum == 0) { hidx = hnum - 1; lidx = ~ (unsigned HOST_WIDE_INT) 0; } else { hidx = hnum; lidx = lnum - 1; } /* Numerator = Numerator*Index = n*(n-1). */ if (mul_double (lnum, hnum, lidx, hidx, &lnum, &hnum)) return NULL_TREE; for (i = 3; i <= k; i++) { /* Index--. */ if (lidx == 0) { hidx--; lidx = ~ (unsigned HOST_WIDE_INT) 0; } else lidx--; /* Numerator *= Index. */ if (mul_double (lnum, hnum, lidx, hidx, &lnum, &hnum)) return NULL_TREE; /* Denominator *= i. */ mul_double (ldenom, hdenom, i, 0, &ldenom, &hdenom); } /* Result = Numerator / Denominator. */ div_and_round_double (EXACT_DIV_EXPR, 1, lnum, hnum, ldenom, hdenom, &lres, &hres, &ldum, &hdum); res = build_int_cst_wide (type, lres, hres); return int_fits_type_p (res, type) ? res : NULL_TREE; }