Improve sqrt handling of large integers and large and small rationals.
authorMark H Weaver <mhw@netris.org>
Wed, 20 Mar 2013 10:15:32 +0000 (06:15 -0400)
committerMark H Weaver <mhw@netris.org>
Wed, 20 Mar 2013 10:27:39 +0000 (06:27 -0400)
commitddb717423619cb2c36fb798dc12552b70cd9b0ad
tree2939590c883587426f5f2d08524a6e0d1bcfc523
parent687a87bf012f0c0afa79dd9bebf7d173d1243880
Improve sqrt handling of large integers and large and small rationals.

* libguile/numbers.c (exact_integer_is_perfect_square,
  exact_integer_floor_square_root): New static functions.

  (scm_sqrt): Use SCM_LIKELY.  Add 'scm_t_inum' variable in inum case to
  reduce the number of uses of SCM_I_INUM.  Rename 'mpz_t' variable.
  Remove unneeded sign check.  Handle bignums too large to fit in a
  double.  Handle fractions too large or too small to fit in a
  normalized double.

* test-suite/tests/numbers.test ("sqrt"): Add tests.
libguile/numbers.c
test-suite/tests/numbers.test