[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 03/07: Fix indentation in scm_sum.
From: |
Mark H. Weaver |
Subject: |
[Guile-commits] 03/07: Fix indentation in scm_sum. |
Date: |
Tue, 7 May 2019 04:46:50 -0400 (EDT) |
mhw pushed a commit to branch stable-2.2
in repository guile.
commit 74d536bf52c682ea71bb94f2e909ff24f98ebc1d
Author: Mark H Weaver <address@hidden>
Date: Mon May 6 21:13:18 2019 -0400
Fix indentation in scm_sum.
---
libguile/numbers.c | 135 +++++++++++++++++++++++++++--------------------------
1 file changed, 68 insertions(+), 67 deletions(-)
diff --git a/libguile/numbers.c b/libguile/numbers.c
index 31fdee4..8c24def 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -7551,80 +7551,81 @@ scm_sum (SCM x, SCM y)
{
scm_t_inum xx = SCM_I_INUM (x);
return scm_c_make_rectangular (xx + SCM_COMPLEX_REAL (y),
- SCM_COMPLEX_IMAG (y));
+ SCM_COMPLEX_IMAG (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_FRACTION_DENOMINATOR (y));
+ scm_product (x,
SCM_FRACTION_DENOMINATOR (y))),
+ SCM_FRACTION_DENOMINATOR (y));
else
return scm_wta_dispatch_2 (g_sum, x, y, SCM_ARGn, s_sum);
- } else if (SCM_BIGP (x))
- {
- if (SCM_I_INUMP (y))
- {
- scm_t_inum inum;
- int bigsgn;
- add_big_inum:
- inum = SCM_I_INUM (y);
- if (inum == 0)
- return x;
- 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_remember_upto_here_1 (x);
- /* we know the result will have to be a bignum */
- if (bigsgn == -1)
- return result;
- return scm_i_normbig (result);
- }
- else
- {
- SCM result = scm_i_mkbig ();
- mpz_add_ui (SCM_I_BIG_MPZ (result), SCM_I_BIG_MPZ (x), inum);
- scm_remember_upto_here_1 (x);
- /* we know the result will have to be a bignum */
- if (bigsgn == 1)
- return result;
- return scm_i_normbig (result);
- }
- }
- else if (SCM_BIGP (y))
- {
- SCM result = scm_i_mkbig ();
- int sgn_x = mpz_sgn (SCM_I_BIG_MPZ (x));
- int sgn_y = mpz_sgn (SCM_I_BIG_MPZ (y));
- mpz_add (SCM_I_BIG_MPZ (result),
- SCM_I_BIG_MPZ (x),
- SCM_I_BIG_MPZ (y));
- scm_remember_upto_here_2 (x, y);
- /* we know the result will have to be a bignum */
- if (sgn_x == sgn_y)
- return result;
- return scm_i_normbig (result);
- }
- 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);
- return scm_i_from_double (result);
- }
- else if (SCM_COMPLEXP (y))
- {
- double real_part = (mpz_get_d (SCM_I_BIG_MPZ (x))
- + SCM_COMPLEX_REAL (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_BIGP (x))
+ {
+ if (SCM_I_INUMP (y))
+ {
+ scm_t_inum inum;
+ int bigsgn;
+ add_big_inum:
+ inum = SCM_I_INUM (y);
+ if (inum == 0)
+ return x;
+ 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_remember_upto_here_1 (x);
+ /* we know the result will have to be a bignum */
+ if (bigsgn == -1)
+ return result;
+ return scm_i_normbig (result);
+ }
+ else
+ {
+ SCM result = scm_i_mkbig ();
+ mpz_add_ui (SCM_I_BIG_MPZ (result), SCM_I_BIG_MPZ (x), inum);
+ scm_remember_upto_here_1 (x);
+ /* we know the result will have to be a bignum */
+ if (bigsgn == 1)
+ return result;
+ return scm_i_normbig (result);
+ }
+ }
+ else if (SCM_BIGP (y))
+ {
+ SCM result = scm_i_mkbig ();
+ int sgn_x = mpz_sgn (SCM_I_BIG_MPZ (x));
+ int sgn_y = mpz_sgn (SCM_I_BIG_MPZ (y));
+ mpz_add (SCM_I_BIG_MPZ (result),
+ SCM_I_BIG_MPZ (x),
+ SCM_I_BIG_MPZ (y));
+ scm_remember_upto_here_2 (x, y);
+ /* we know the result will have to be a bignum */
+ if (sgn_x == sgn_y)
+ return result;
+ return scm_i_normbig (result);
+ }
+ 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);
+ return scm_i_from_double (result);
+ }
+ else if (SCM_COMPLEXP (y))
+ {
+ double real_part = (mpz_get_d (SCM_I_BIG_MPZ (x))
+ + SCM_COMPLEX_REAL (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),
scm_product (x,
SCM_FRACTION_DENOMINATOR (y))),
SCM_FRACTION_DENOMINATOR (y));
- else
- return scm_wta_dispatch_2 (g_sum, x, y, SCM_ARGn, s_sum);
- }
+ else
+ return scm_wta_dispatch_2 (g_sum, x, y, SCM_ARGn, s_sum);
+ }
else if (SCM_REALP (x))
{
if (SCM_I_INUMP (y))
- [Guile-commits] branch stable-2.2 updated (6381845 -> 7c2b48a), Mark H. Weaver, 2019/05/07
- [Guile-commits] 02/07: Fix typo in comment., Mark H. Weaver, 2019/05/07
- [Guile-commits] 05/07: Optimize fixnum exact integer square roots., Mark H. Weaver, 2019/05/07
- [Guile-commits] 03/07: Fix indentation in scm_sum.,
Mark H. Weaver <=
- [Guile-commits] 04/07: Avoid 'with-latin1-locale' in binary I/O tests., Mark H. Weaver, 2019/05/07
- [Guile-commits] 07/07: Strings, i18n: Limit the use of alloca to approximately 8 kilobytes., Mark H. Weaver, 2019/05/07
- [Guile-commits] 06/07: put-u8: Always write a single byte, regardless of the port encoding., Mark H. Weaver, 2019/05/07
- [Guile-commits] 01/07: Add 'scm_c_make_char' and use it where appropriate., Mark H. Weaver, 2019/05/07