mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-30 17:00:23 +02:00
Fix indentation in scm_sum.
This commit is contained in:
parent
16b4bac355
commit
74d536bf52
1 changed files with 68 additions and 67 deletions
|
@ -7551,80 +7551,81 @@ scm_sum (SCM x, SCM y)
|
||||||
{
|
{
|
||||||
scm_t_inum xx = SCM_I_INUM (x);
|
scm_t_inum xx = SCM_I_INUM (x);
|
||||||
return scm_c_make_rectangular (xx + SCM_COMPLEX_REAL (y),
|
return scm_c_make_rectangular (xx + SCM_COMPLEX_REAL (y),
|
||||||
SCM_COMPLEX_IMAG (y));
|
SCM_COMPLEX_IMAG (y));
|
||||||
}
|
}
|
||||||
else if (SCM_FRACTIONP (y))
|
else if (SCM_FRACTIONP (y))
|
||||||
return scm_i_make_ratio (scm_sum (SCM_FRACTION_NUMERATOR (y),
|
return scm_i_make_ratio (scm_sum (SCM_FRACTION_NUMERATOR (y),
|
||||||
scm_product (x, SCM_FRACTION_DENOMINATOR (y))),
|
scm_product (x, SCM_FRACTION_DENOMINATOR (y))),
|
||||||
SCM_FRACTION_DENOMINATOR (y));
|
SCM_FRACTION_DENOMINATOR (y));
|
||||||
else
|
else
|
||||||
return scm_wta_dispatch_2 (g_sum, x, y, SCM_ARGn, s_sum);
|
return scm_wta_dispatch_2 (g_sum, x, y, SCM_ARGn, s_sum);
|
||||||
} else if (SCM_BIGP (x))
|
}
|
||||||
{
|
else if (SCM_BIGP (x))
|
||||||
if (SCM_I_INUMP (y))
|
{
|
||||||
{
|
if (SCM_I_INUMP (y))
|
||||||
scm_t_inum inum;
|
{
|
||||||
int bigsgn;
|
scm_t_inum inum;
|
||||||
add_big_inum:
|
int bigsgn;
|
||||||
inum = SCM_I_INUM (y);
|
add_big_inum:
|
||||||
if (inum == 0)
|
inum = SCM_I_INUM (y);
|
||||||
return x;
|
if (inum == 0)
|
||||||
bigsgn = mpz_sgn (SCM_I_BIG_MPZ (x));
|
return x;
|
||||||
if (inum < 0)
|
bigsgn = mpz_sgn (SCM_I_BIG_MPZ (x));
|
||||||
{
|
if (inum < 0)
|
||||||
SCM result = scm_i_mkbig ();
|
{
|
||||||
mpz_sub_ui (SCM_I_BIG_MPZ (result), SCM_I_BIG_MPZ (x), - inum);
|
SCM result = scm_i_mkbig ();
|
||||||
scm_remember_upto_here_1 (x);
|
mpz_sub_ui (SCM_I_BIG_MPZ (result), SCM_I_BIG_MPZ (x), - inum);
|
||||||
/* we know the result will have to be a bignum */
|
scm_remember_upto_here_1 (x);
|
||||||
if (bigsgn == -1)
|
/* we know the result will have to be a bignum */
|
||||||
return result;
|
if (bigsgn == -1)
|
||||||
return scm_i_normbig (result);
|
return result;
|
||||||
}
|
return scm_i_normbig (result);
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
SCM result = scm_i_mkbig ();
|
{
|
||||||
mpz_add_ui (SCM_I_BIG_MPZ (result), SCM_I_BIG_MPZ (x), inum);
|
SCM result = scm_i_mkbig ();
|
||||||
scm_remember_upto_here_1 (x);
|
mpz_add_ui (SCM_I_BIG_MPZ (result), SCM_I_BIG_MPZ (x), inum);
|
||||||
/* we know the result will have to be a bignum */
|
scm_remember_upto_here_1 (x);
|
||||||
if (bigsgn == 1)
|
/* we know the result will have to be a bignum */
|
||||||
return result;
|
if (bigsgn == 1)
|
||||||
return scm_i_normbig (result);
|
return result;
|
||||||
}
|
return scm_i_normbig (result);
|
||||||
}
|
}
|
||||||
else if (SCM_BIGP (y))
|
}
|
||||||
{
|
else if (SCM_BIGP (y))
|
||||||
SCM result = scm_i_mkbig ();
|
{
|
||||||
int sgn_x = mpz_sgn (SCM_I_BIG_MPZ (x));
|
SCM result = scm_i_mkbig ();
|
||||||
int sgn_y = mpz_sgn (SCM_I_BIG_MPZ (y));
|
int sgn_x = mpz_sgn (SCM_I_BIG_MPZ (x));
|
||||||
mpz_add (SCM_I_BIG_MPZ (result),
|
int sgn_y = mpz_sgn (SCM_I_BIG_MPZ (y));
|
||||||
SCM_I_BIG_MPZ (x),
|
mpz_add (SCM_I_BIG_MPZ (result),
|
||||||
SCM_I_BIG_MPZ (y));
|
SCM_I_BIG_MPZ (x),
|
||||||
scm_remember_upto_here_2 (x, y);
|
SCM_I_BIG_MPZ (y));
|
||||||
/* we know the result will have to be a bignum */
|
scm_remember_upto_here_2 (x, y);
|
||||||
if (sgn_x == sgn_y)
|
/* we know the result will have to be a bignum */
|
||||||
return result;
|
if (sgn_x == sgn_y)
|
||||||
return scm_i_normbig (result);
|
return result;
|
||||||
}
|
return scm_i_normbig (result);
|
||||||
else if (SCM_REALP (y))
|
}
|
||||||
{
|
else if (SCM_REALP (y))
|
||||||
double result = mpz_get_d (SCM_I_BIG_MPZ (x)) + SCM_REAL_VALUE (y);
|
{
|
||||||
scm_remember_upto_here_1 (x);
|
double result = mpz_get_d (SCM_I_BIG_MPZ (x)) + SCM_REAL_VALUE (y);
|
||||||
return scm_i_from_double (result);
|
scm_remember_upto_here_1 (x);
|
||||||
}
|
return scm_i_from_double (result);
|
||||||
else if (SCM_COMPLEXP (y))
|
}
|
||||||
{
|
else if (SCM_COMPLEXP (y))
|
||||||
double real_part = (mpz_get_d (SCM_I_BIG_MPZ (x))
|
{
|
||||||
+ SCM_COMPLEX_REAL (y));
|
double real_part = (mpz_get_d (SCM_I_BIG_MPZ (x))
|
||||||
scm_remember_upto_here_1 (x);
|
+ SCM_COMPLEX_REAL (y));
|
||||||
return scm_c_make_rectangular (real_part, SCM_COMPLEX_IMAG (y));
|
scm_remember_upto_here_1 (x);
|
||||||
}
|
return scm_c_make_rectangular (real_part, SCM_COMPLEX_IMAG (y));
|
||||||
else if (SCM_FRACTIONP (y))
|
}
|
||||||
return scm_i_make_ratio (scm_sum (SCM_FRACTION_NUMERATOR (y),
|
else if (SCM_FRACTIONP (y))
|
||||||
|
return scm_i_make_ratio (scm_sum (SCM_FRACTION_NUMERATOR (y),
|
||||||
scm_product (x, SCM_FRACTION_DENOMINATOR (y))),
|
scm_product (x, SCM_FRACTION_DENOMINATOR (y))),
|
||||||
SCM_FRACTION_DENOMINATOR (y));
|
SCM_FRACTION_DENOMINATOR (y));
|
||||||
else
|
else
|
||||||
return scm_wta_dispatch_2 (g_sum, x, y, SCM_ARGn, s_sum);
|
return scm_wta_dispatch_2 (g_sum, x, y, SCM_ARGn, s_sum);
|
||||||
}
|
}
|
||||||
else if (SCM_REALP (x))
|
else if (SCM_REALP (x))
|
||||||
{
|
{
|
||||||
if (SCM_I_INUMP (y))
|
if (SCM_I_INUMP (y))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue