| Commit message (Expand) | Author | Age | Files | Lines |
* | Do not assume that sizeof (long) == sizeof (void *) == sizeof (SCM)....This assumption does not hold on systems that use the LLP64 data model.
Partially fixes <https://debbugs.gnu.org/22406>.
Reported by Peter TB Brett <peter@peter-b.co.uk>.
* libguile/numbers.h (scm_t_inum): Move here from numbers.c, and change
to be equivalent to 'long' (formerly 'scm_t_signed_bits').
(SCM_MOST_POSITIVE_FIXNUM, SCM_MOST_NEGATIVE_FIXNUM): Define based on
SCM_I_FIXNUM_BIT instead of SCM_T_SIGNED_BITS_MAX.
(SCM_I_INUM): Adjust definitions to return a 'scm_t_inum', and avoiding
the assumption that SCM_UNPACK returns a 'long'.
* libguile/numbers.c (scm_t_inum): Move definition to numbers.h.
Verify that 'scm_t_inum' fits within a SCM value.
(scm_i_inum2big): Remove preprocessor code that forced a compile error
unless sizeof (long) == sizeof (void *).
| Mark H Weaver | 2017-03-01 | 1 | -7/+3 |
* | Avoid signed integer overflows in numeric conversions....Reported by Miroslav Lichvar <mlichvar@redhat.com>
in <https://lists.gnu.org/archive/html/guile-devel/2016-02/msg00045.html>
* libguile/conv-integer.i.c: Avoid signed overflow.
* libguile/numbers.c (scm_is_signed_integer): Avoid signed overflow.
| Mark H Weaver | 2017-03-01 | 1 | -5/+10 |
* | Fix (* x -1) for GOOPS types...* libguile/numbers.c (scm_product): Only reduce (* x -1) to (- x) when X
is a bignum. Fixes weirdness when X is not a number and instead
multiplication should dispatch to GOOPS. Thanks to Alejandro Sanchez
for the report.
| Andy Wingo | 2017-02-28 | 1 | -15/+13 |
* | Use labs instead of abs where needed...* libguile/numbers.c (log_of_fraction): Use labs instead of abs on
longs. Thanks to Matt Wette for the tip.
| Andy Wingo | 2017-02-21 | 1 | -1/+1 |
* | Fix make-polar signedness of zeros on macOS...* configure.ac: Check for __sincos.
* libguile/numbers.c (scm_c_make_polar): Fall back to __sincos if
possible. Fixes zero signedness of make-polar on macOS.
| Matt Wette | 2017-02-21 | 1 | -0/+2 |
* | Speed up number->string...* libguile/numbers.c (scm_number_to_string): Use scm_from_latin1_string
where appropriate. Avoids mucking about with iconv.
| Andy Wingo | 2017-02-17 | 1 | -3/+3 |
* | Deprecate dynamic roots...* libguile/root.h:
* libguile/root.c: Remove these files.
* libguile/deprecated.h:
* libguile/deprecated.c (scm_internal_cwdr, scm_call_with_dynamic_root)
(scm_dynamic_root, scm_apply_with_dynamic_root): Deprecate.
Remove all root.h usage, which was vestigial.
* module/ice-9/serialize.scm: Use (current-thread) instead
of (dynamic-root).
| Andy Wingo | 2016-11-21 | 1 | -1/+0 |
* | Fix atan procedure when applied to complex numbers....Fixes a regression introduced in commit
ad79736c68a803a59814fbfc0cb4b092c2b4cddf.
* libguile/numbers.c (scm_atan): Fix the complex case.
* test-suite/tests/numbers.test ("atan"): Add test.
| Mark H Weaver | 2016-05-22 | 1 | -2/+2 |
* | Don't return expressions from void functions in numbers.c...Although popular compilers allow it as long as the expression is of type
void, it violates C99 and some compilers choke on it.
* libguile/numbers.c (scm_euclidean_divide, scm_floor_divide)
(scm_ceiling_divide, scm_truncate_divide, scm_centered_divide)
(scm_round_divide): Don't use the return statement with an expression
from functions with return type void.
| Mark H Weaver | 2016-05-22 | 1 | -138/+108 |
* | scm_lfwrite, not scm_lfwrite_unlocked...* libguile/ports.h (scm_lfwrite_unlocked): Remove.
* libguile/ports.c (scm_lfwrite): Rename from scm_lfwrite_unlocked.
* libguile/numbers.c:
* libguile/print.c: Adapt to call scm_lfwrite.
| Andy Wingo | 2016-04-26 | 1 | -5/+5 |
* | Merge branch 'stable-2.0'...Conflicts:
GUILE-VERSION
NEWS
guile-readline/ice-9/readline.scm
libguile/async.c
libguile/backtrace.c
libguile/deprecated.h
libguile/gc-malloc.c
libguile/gdbint.c
libguile/init.c
libguile/ioext.c
libguile/mallocs.c
libguile/print.c
libguile/rw.c
libguile/scmsigs.c
libguile/script.c
libguile/simpos.c
libguile/snarf.h
libguile/strports.c
libguile/threads.c
libguile/vm-i-scheme.c
libguile/vm-i-system.c
module/srfi/srfi-18.scm
test-suite/Makefile.am
test-suite/standalone/test-num2integral.c
| Mark H Weaver | 2014-04-25 | 1 | -5/+11 |
|\ |
|
| * | Avoid undefined behavior regarding signed integers and left shifts....* libguile/numbers.c (scm_logbit_p): If the requested bit is the sign
bit (or above), check the sign portably. Otherwise, ensure that we're
testing the bit in a two's complement representation.
(left_shift_exact_integer): Avoid left-shifting negative integers.
* libguile/vm-i-scheme.c (ash): Avoid left-shifting negative integers.
| Mark H Weaver | 2014-03-11 | 1 | -6/+12 |
* | | Merge branch 'stable-2.0'...Conflicts:
module/system/vm/traps.scm
test-suite/tests/peval.test
| Mark H Weaver | 2014-01-09 | 1 | -2/+21 |
|\| |
|
| * | Implement 'exact-integer?' and 'scm_is_exact_integer'....* libguile/numbers.c (scm_exact_integer_p, scm_is_exact_integer):
New procedures.
(scm_integer_p): Improve docstring.
* libguile/numbers.h (scm_exact_integer_p, scm_is_exact_integer):
New prototypes.
* doc/ref/api-data.texi (Integers): Add docs.
* test-suite/tests/numbers.test ("exact-integer?"): Add tests.
| Mark H Weaver | 2014-01-08 | 1 | -2/+21 |
* | | Merge commit 'd360671c1cca335600079f1c5714572d1c2e676d' | Andy Wingo | 2013-11-28 | 1 | -1/+1 |
|\| |
|
| * | Fix edge case in 'ash'....* libguile/numbers.c (left_shift_exact_integer): Fix edge case where
N is -1 and count is SCM_I_FIXNUM_BIT-1 to return the most negative
fixnum. Previously this result was returned as a bignum.
* test-suite/tests/numbers.test (ash): Add tests.
| Mark H Weaver | 2013-10-03 | 1 | -3/+6 |
| * | Revert "Fix edge case in 'ash'."...This reverts commit 8df68898b9f6ba15171244f1f3549688f13d605f.
| Mark H Weaver | 2013-10-03 | 1 | -7/+4 |
* | | Merge remote-tracking branch 'origin/stable-2.0'...Conflicts:
libguile/deprecated.h
libguile/programs.c
libguile/programs.h
| Andy Wingo | 2013-10-03 | 1 | -4/+7 |
|\| |
|
| * | Fix edge case in 'ash'....* libguile/numbers.c (scm_ash): Fix (ash -1 SCM_I_FIXNUM_BIT-1) to
return a fixnum instead of a bignum.
* test-suite/tests/numbers.test (ash): Add tests.
| Mark H Weaver | 2013-10-03 | 1 | -4/+7 |
* | | Micro-optimize char_decimal_value....* libguile/numbers.c (char_decimal_value): A wee micro-optimization.
| Andy Wingo | 2013-08-31 | 1 | -12/+17 |
* | | Merge remote-tracking branch 'origin/stable-2.0' | Mark H Weaver | 2013-08-11 | 1 | -6/+23 |
|\| |
|
| * | Fix inappropriate uses of scm_syserror in numbers.c....* libguile/numbers.c (mem2ureal, left_shift_exact_integer,
floor_right_shift_exact_integer, round_right_shift_exact_integer):
Use 'assert' instead of 'scm_syserror' to indicate a case that should
never happen.
| Mark H Weaver | 2013-08-10 | 1 | -4/+5 |
| * | Fix numerator and denominator handling of signed zeroes and infinities....* libguile/numbers.c (scm_numerator, scm_denominator): Handle signed
zeroes and infinities in accordance with the corresponding R6RS flonum
procedures.
* module/rnrs/arithmetic/flonums.scm (flnumerator, fldenominator):
Remove special handling of infinities.
* test-suite/tests/numbers.test (numerator, denominator): Add tests.
Convert existing tests to use 'pass-if-equal'.
* test-suite/tests/r6rs-arithmetic-flonums.test (flnumerator): Fix
broken test of (flnumerator -0.0).
| Mark H Weaver | 2013-08-09 | 1 | -2/+18 |
* | | Eliminate use of deprecated 'SCM_WTA_DISPATCH_2' in numbers.c....* libguile/numbers.c (scm_gcd): Use 'scm_wta_dispatch_2' not
'SCM_WTA_DISPATCH_2'.
| Mark H Weaver | 2013-08-08 | 1 | -1/+1 |
* | | Merge remote-tracking branch 'origin/stable-2.0'...Conflicts:
libguile/numbers.c
libguile/vm-i-scheme.c
| Mark H Weaver | 2013-08-06 | 1 | -222/+312 |
|\| |
|
| * | Use Gnulib's 'isfinite' in numbers.c....* libguile/numbers.c (DOUBLE_IS_FINITE, DOUBLE_IS_POSITIVE_INFINITY,
DOUBLE_IS_NEGATIVE_INFINITY): Remove.
(scm_odd_p, scm_even_p, scm_finite_p, icmplx2str, scm_rational_p,
scm_inexact_to_exact): Use 'isfinite' instead of 'DOUBLE_IS_FINITE'.
| Mark H Weaver | 2013-08-06 | 1 | -15/+6 |
| * | Use Gnulib's 'copysign' in numbers.c....* libguile/numbers.c (double_is_non_negative_zero): Remove.
(idbl2str, scm_max, scm_min, scm_angle, log_of_shifted_double,
scm_log10): Use 'copysign' to check signs of zeroes,
instead of 'double_is_non_negative_zero'.
| Mark H Weaver | 2013-08-06 | 1 | -18/+10 |
| * | Add 'scm_i_from_double' and use it....* libguile/numbers.c (scm_i_from_double): New static function.
(scm_from_double): Just call 'scm_i_from_double'.
(scm_inf, scm_nan, scm_abs, scm_i_inexact_floor_quotient,
scm_i_inexact_floor_remainder, scm_i_inexact_floor_divide,
scm_i_inexact_ceiling_quotient, scm_i_inexact_ceiling_remainder,
scm_i_inexact_ceiling_divide, scm_i_inexact_truncate_quotient,
scm_i_inexact_truncate_remainder, scm_i_inexact_truncate_divide,
scm_i_inexact_centered_quotient, scm_i_inexact_centered_remainder,
scm_i_inexact_centered_divide, scm_i_inexact_round_quotient,
scm_i_inexact_round_remainder, scm_i_inexact_round_divide,
scm_max, scm_min, scm_sum, scm_difference, scm_product,
scm_divide, scm_truncate_number, scm_round_number, scm_floor,
scm_ceiling, scm_expt, scm_sin, scm_cos, scm_tan, scm_sinh,
scm_cosh, scm_tanh, scm_asin, scm_acos, scm_atan, scm_sys_asinh,
scm_sys_acosh, scm_sys_atanh, scm_real_part, scm_imag_part,
scm_magnitude, scm_angle, scm_exact_to_inexact, log_of_shifted_double,
log_of_fraction, scm_log10, scm_exp, scm_sqrt, scm_init_numbers):
Use 'scm_i_from_double' instead of 'scm_from_double'.
| Mark H Weaver | 2013-08-02 | 1 | -117/+123 |
| * | Fix minor formatting error in 'rationalize'....* libguile/numbers.c (scm_rationalize): Fix formatting.
| Mark H Weaver | 2013-07-21 | 1 | -2/+2 |
| * | Rewrite 'rationalize' to fix bugs and improve efficiency....Fixes <http://bugs.gnu.org/14905>.
Reported by Göran Weinholt <goran@weinholt.se>.
* libguile/numbers.c (scm_rationalize): Rewrite. Previously an
incorrect algorithm was used which failed in many cases.
* test-suite/tests/numbers.test (rationalize): Add tests.
| Mark H Weaver | 2013-07-21 | 1 | -76/+177 |
* | | Merge remote-tracking branch 'origin/stable-2.0'...Conflicts:
libguile/numbers.c
| Mark H Weaver | 2013-07-16 | 1 | -27/+53 |
|\| |
|
| * | gcd and lcm support inexact integer arguments....Fixes <http://bugs.gnu.org/14870>.
Reported by Göran Weinholt <goran@weinholt.se>.
* libguile/numbers.c (scm_gcd, scm_lcm): Support inexact integers.
* test-suite/tests/numbers.test (gcd, lcm): Add tests.
| Mark H Weaver | 2013-07-16 | 1 | -16/+45 |
| * | min and max: NaNs beat infinities, per R6RS errata....Fixes <http://bugs.gnu.org/14865>.
Reported by Göran Weinholt <goran@weinholt.se>.
* libguile/numbers.c (scm_min, scm_max): NaNs beat infinities, as per
the R6RS errata.
* test-suite/tests/numbers.test (min, max): Update tests.
| Mark H Weaver | 2013-07-16 | 1 | -10/+8 |
* | | Merge remote-tracking branch 'origin/stable-2.0'...Conflicts:
libguile/keywords.c
libguile/vm.c
| Mark H Weaver | 2013-07-16 | 1 | -33/+82 |
|\| |
|
| * | Avoid lossy conversion from inum to double in numerical comparisons....* libguile/numbers.c (scm_less_p): Avoid converting inums to doubles.
* test-suite/tests/numbers.test (<): Add tests.
| Mark H Weaver | 2013-07-16 | 1 | -2/+38 |
| * | Fix bugs in numerical equality predicate....* libguile/numbers.c (scm_num_eq_p): Fix bug comparing fractions to
infinities (reported by Göran Weinholt <goran@weinholt.se>). Fix
erroneous comment describing the logic behind inum/flonum comparison.
Use similar logic for inum/complex comparison to avoid rounding
errors. Make minor indentation fixes and simplifications.
* test-suite/tests/numbers.test (=): Add tests.
| Mark H Weaver | 2013-07-16 | 1 | -27/+33 |
| * | Fix rounding in scm_i_divide2double for negative arguments....* libguile/numbers.c (INUM_LOSSLESSLY_CONVERTIBLE_TO_DOUBLE):
New macro.
(scm_i_divide2double): Use INUM_LOSSLESSLY_CONVERTIBLE_TO_DOUBLE to
determine if our fast path is safe. Previously, negative arguments
were not checked properly.
* test-suite/tests/numbers.test (exact->inexact): Add tests.
| Mark H Weaver | 2013-07-16 | 1 | -4/+11 |
* | | Merge remote-tracking branch 'origin/stable-2.0' | Mark H Weaver | 2013-03-28 | 1 | -1/+30 |
|\| |
|
| * | Allow compilation with GMP < 5.0.0....* libguile/numbers.c (VARARG_MPZ_ITERATOR)[!HAVE_DECL_MPZ_INITS]: New
macro.
(mpz_inits, mpz_clears)[!HAVE_DECL_MPZ_INITS]: New functions.
* configure.ac: Check for the declaration of `mpz_inits'.
| Ludovic Courtès | 2013-03-28 | 1 | -1/+30 |
* | | Merge remote-tracking branch 'origin/stable-2.0'...Conflicts:
configure.ac
libguile/deprecated.c
libguile/deprecated.h
libguile/filesys.h
libguile/fluids.c
libguile/fports.c
libguile/gc.c
libguile/guile.c
libguile/numbers.c
libguile/objcodes.c
libguile/r6rs-ports.c
libguile/smob.c
libguile/socket.c
libguile/threads.h
module/language/scheme/decompile-tree-il.scm
module/language/tree-il/peval.scm
test-suite/tests/syncase.test
| Mark H Weaver | 2013-03-28 | 1 | -606/+1038 |
|\| |
|
| * | 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.
| Mark H Weaver | 2013-03-20 | 1 | -21/+112 |
| * | Optimize inum case of exact-integer-sqrt....* libguile/numbers.c (scm_exact_integer_sqrt): Use GMP for inum
case. It is faster than what we had before.
| Mark H Weaver | 2013-03-20 | 1 | -16/+8 |
| * | Sqrt returns exact results when possible....* libguile/numbers.c (scm_sqrt): Handle exact integers and rationals in
such a way that exact results are returned whenever possible.
* test-suite/tests/numbers.test ("sqrt"): Add tests.
| Mark H Weaver | 2013-03-20 | 1 | -5/+64 |
| * | Optimize scm_i_divide2double for integers less than 2^DBL_MANT_DIG....* libguile/numbers.c (scm_i_divide2double): Optimize for common case
when both operands are less than 2^DBL_MANT_DIG (normally 2^53).
| Mark H Weaver | 2013-03-19 | 1 | -1/+11 |
| * | Use scientific notation only if there are enough trailing zeroes....* libguile/numbers.c (idbl2str): Print large numbers in scientific
notation only if the exponent is >= 7 and the least significant
non-zero digit has value >= radix^4.
* test-suite/tests/numbers.test ("number->string"): Add tests.
| Mark H Weaver | 2013-03-19 | 1 | -17/+46 |
| * | Reimplement idbl2str number printer....Fixes <http://bugs.gnu.org/13757>.
* libguile/numbers.c (idbl2str): Reimplement.
(mem2decimal_from_point): Accept negative exponents larger than
SCM_MAXEXP that produce subnormals.
(SCM_MAX_DBL_PREC): Removed preprocessor macro.
(scm_dblprec, fx_per_radix): Removed static variables.
(init_dblprec, init_fx_radix): Removed static functions.
(scm_init_numbers): Remove initialization code for 'scm_dblprec'
and 'fx_per_radix'.
* test-suite/tests/numbers.test ("number->string"): Restore tests that
previously failed. Remove comments about problems in the number
printer that are now fixed.
| Mark H Weaver | 2013-03-17 | 1 | -212/+179 |
| * | Improve inexact division of exact integers....* libguile/numbers.c (scm_i_divide2double): New function.
(scm_i_divide2double_lo2b): New variable.
(scm_i_fraction2double, log_of_fraction): Use 'scm_i_divide2double'.
(do_divide): Removed. Its code is now in 'scm_divide'.
(scm_divide2real): Removed. Superceded by 'scm_i_divide2double'.
(scm_divide): Inherit code from 'do_divide', but without support for
forcing a 'double' result (that functionality is now implemented by
'scm_i_divide2double'). Add FIXME comments in cases where divisions
might not be as precise as they should be.
(scm_init_numbers): Initialize 'scm_i_divide2double_lo2b'.
* test-suite/tests/numbers.test (dbl-epsilon-exact, dbl-max-exp): New
variables.
("exact->inexact"): Add tests.
("inexact->exact"): Add test for largest finite inexact.
| Mark H Weaver | 2013-03-17 | 1 | -80/+204 |
| * | Reimplement 'inexact->exact' to avoid mpq functions....* libguile/numbers.c (scm_inexact_to_exact): Implement conversion of a
double to an exact rational without using the mpq functions.
* test-suite/tests/numbers.test (dbl-mant-dig): Simplify initializer.
(dbl-epsilon, dbl-min-exp): New variables.
("inexact->exact"): Add tests. Fix broken "2.0**i to exact and back"
test, and change it to "2.0**i to exact", to avoid use of
'exact->inexact'.
| Mark H Weaver | 2013-03-12 | 1 | -14/+27 |
| * | Optimize logarithms using scm_i_big2dbl_2exp...* libguile/numbers.c (log_of_exact_integer_with_size): Removed.
(log_of_exact_integer): Handle bignums too large to fit in a double
using 'scm_i_big2dbl_2exp' instead of 'scm_integer_length' and
'scm_ash'.
(log_of_fraction): Use 'log_of_exact_integer' instead of
'log_of_exact_integer_with_size'.
| Mark H Weaver | 2013-03-12 | 1 | -18/+12 |
| * | Simplify and improve scm_i_big2dbl, and add scm_i_big2dbl_2exp...* libguile/numbers.c (scm_i_big2dbl_2exp): New static function.
(scm_i_big2dbl): Reimplement in terms of 'scm_i_big2dbl_2exp',
with proper rounding.
* test-suite/tests/numbers.test ("exact->inexact"): Add tests.
| Mark H Weaver | 2013-03-12 | 1 | -65/+36 |