1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-01 04:10:18 +02:00
Commit graph

301 commits

Author SHA1 Message Date
Neil Jerram
0bf4fe19a6 Fix for incorrect (gcd -2) => -2; should give 2.
(reported by Bill Schottstaedt)

* libguile/numbers.c (scm_gcd): When only one arg given, use scm_abs
  to ensure that result is non-negative.

* test-suite/tests/numbers.test ("gcd"): New test, (gcd -2).
2008-09-22 21:18:01 +01:00
Ludovic Courtès
7a4e0d105e Include <config.h> in all C files; use #ifdef HAVE_CONFIG_H' rather than #if'. 2008-09-13 15:49:50 +02:00
Ludovic Courtès
e210266510 Use AC_USE_SYSTEM_EXTENSIONS' instead of the obsolete AC_AIX', etc. 2008-08-20 19:02:41 +02:00
Neil Jerram
7ed52b7bbb Fix misleading output from `(help rationalize)'
* numbers.c (scm_rationalize): Update docstring to match the
	manual (which is more correct).  Change argument "err" to "eps",
	also to match the manual.
2008-08-03 00:18:33 +01:00
Ludovic Courtès
19da7c42c1 Avoid warning with GCC on FreeBSD 6.2 in `numbers.c'. 2008-05-07 17:43:17 +02:00
Neil Jerram
607dc3105d Only define scm_from_complex_double if it will
actually be used.
2008-03-09 21:53:25 +00:00
Ludovic Courtès
024134deb3 Use imaginary_part' instead of imaginary' to fix build on Solaris 2.10. 2008-02-23 10:33:33 +00:00
Neil Jerram
03a3c619ed * numbers.c (SCM_COMPLEX_VALUE): Use GUILE_I instead of _Complex_I
directly, and only if GUILE_I was defined by the configure step.
(scm_log, scm_log10, scm_exp, scm_sqrt): Use SCM_COMPLEX_VALUE
code only if SCM_COMPLEX_VALUE is defined.

* configure.in (--without-64-calls): Use AC_MSG_CHECKING and
AC_MSG_RESULT instead of just echo.
(GUILE_I): New programs to try using _Complex_I or 1.0fi for the
imaginary unit.
2008-02-11 21:02:15 +00:00
Ludovic Courtès
136cddb3e4 Fix compilation of `numbers.c' with Sun CC. 2008-02-06 13:17:51 +00:00
Ludovic Courtès
dbbed1aa14 Changes from arch/CVS synchronization 2007-12-08 16:33:26 +00:00
Kevin Ryde
1cd24a3942 (scm_log): Test HAVE_CLOG as well as HAVE_COMPLEX_DOUBLE
before using clog().  It's possible for gcc to provide the "complex
double" type, but for the system not to have the complex funcs.
(scm_exp): Ditto HAVE_CEXP for cexp().
2007-09-02 22:25:41 +00:00
Han-Wen Nienhuys
f82ca609d3 * numbers.c (scm_i_fraction_reduce): move logic into
scm_i_make_ratio(), so fractions are only read.
scm_i_fraction_reduce() modifies a fraction when reading it.  A
race condition might lead to fractions being corrupted by reading
them concurrently.

* numbers.h: remove SCM_FRACTION_SET_NUMERATOR,
SCM_FRACTION_SET_DENOMINATOR, SCM_FRACTION_REDUCED_BIT,
SCM_FRACTION_REDUCED_SET, SCM_FRACTION_REDUCED_CLEAR,
SCM_FRACTION_REDUCED.
2006-12-23 20:55:47 +00:00
Kevin Ryde
924a59a7b9 (scm_product): For flonum*inum and complex*inum, return
exact 0 if inum==0.  Already done for inum*flonum and inum*complex,
and as per R5RS section "Exactness".
2006-12-05 00:58:04 +00:00
Kevin Ryde
14838b6b40 (scm_log10): Check HAVE_CLOG10, not available in mingw. 2006-09-27 01:34:44 +00:00
Kevin Ryde
c82f332e1e More of:
* numbers.c, numbers.h (scm_log, scm_log10, scm_exp, scm_sqrt): New
	functions.
2006-09-23 01:16:50 +00:00
Kevin Ryde
0a1aa8536e (scm_log, scm_log10, scm_exp, scm_sqrt): New functions. 2006-09-22 23:19:20 +00:00
Ludovic Courtès
71aa2c6c7b Changes from arch/CVS synchronization 2006-07-12 08:15:57 +00:00
Kevin Ryde
65581bc84d (scm_i_divide): For big/big wanting inexact, use mpq_get_d
rather than converting to doubles, to avoid inf or nan when the inputs
are too big for a double but the quotient does fit.  This affects
conversions exact->inexact of big fractions.
2006-05-09 00:25:11 +00:00
Kevin Ryde
2d25ec1981 2006-03-21 Ludovic Courtès <ludovic.courtes@laas.fr>
* numbers.c (scm_i_mem2number): Renamed to
	scm_c_locale_stringn_to_number.
	* numbers.c, print.c, read.c: Updated callers.
2006-03-21 00:45:09 +00:00
Marius Vollmer
0ab652a386 Added 2006 to copyright years in every file, as per the new rules. 2006-02-12 13:42:52 +00:00
Marius Vollmer
3a1b45fdf7 Use scm_from_bool instead of SCM_BOOL. Thanks to Peter Gavin! 2005-08-11 21:03:58 +00:00
Marius Vollmer
92205699d0 The FSF has a new address. 2005-05-23 19:57:22 +00:00
Kevin Ryde
4c6e36a6e3 (scm_divide): Correction to 1/complex and <any>/complex,
need to test abs(re)<abs(im) for choice of cases, otherwise divide by
zero when re==0 and im<0.  Reported by Jean Crepeau.
2005-04-29 22:59:22 +00:00
Kevin Ryde
40882e3d0b (scm_oneplus, scm_oneminus): New functions, converted from
scheme code in boot-9.scm.
2005-04-14 00:35:50 +00:00
Kevin Ryde
23c3b605b5 (scm_i_clonebig): Remove static, so can use in srfi-60. 2005-03-13 00:18:34 +00:00
Kevin Ryde
9806de0dca (scm_logior): Must scm_i_normbig results as per scm_logand,
because OR-ing bits into a negative can reduce the value to an inum.
2005-03-13 00:16:22 +00:00
Kevin Ryde
e8c5b1f291 (scm_num_eq_p): On 64-bit systems, be careful about
casting inum to double since that can lose precision.
2005-03-13 00:13:10 +00:00
Kevin Ryde
7d92d3d0da Add a copyright year. 2005-02-14 23:15:08 +00:00
Kevin Ryde
a9ad484720 In scm_difference, amend comment about normbig. 2005-02-14 23:14:35 +00:00
Kevin Ryde
788aca275f (scm_ash): Rewrite using shifts, much faster than
integer-expt and multiply/divide.  Inexacts and fractions no longer
supported (they happened to work before for left shifts, but not
right).  Don't really need inexacts and fractions, since ash is
documented as a "bitwise operation", and all the rest of those only
take exact integers.
2005-01-27 22:51:22 +00:00
Kevin Ryde
ba6e7231e4 (scm_logtest, scm_logbit_p, scm_integer_expt): Update
docstrings from manual.
2005-01-15 00:01:40 +00:00
Kevin Ryde
66b1c775d2 (scm_modulo): Amend fixme comment about negative divisor
with "%", C99 says it's well-defined.
2004-12-10 00:00:27 +00:00
Marius Vollmer
7a1aba42cf (scm_i_print_complex, icmplx2str): New.
(iflo2str): Use icmplx2str for complex numbers.
2004-10-29 14:17:20 +00:00
Marius Vollmer
b479fe9ae4 (scm_i_print_double): New. 2004-10-26 16:53:23 +00:00
Marius Vollmer
2881e77b5a (SCM_T_INTBUFLEN): Increased to cover
scm_t_intmax values.
(scm_uint2str): New, for scm_t_uintmax.
(scm_iint2str): Argument type changed to scm_t_intmax,
reimplemented in terms of scm_uint2str.
2004-10-22 13:50:39 +00:00
Marius Vollmer
1713d319b7 * numbers.c (scm_i_range_error): New.
* conv-integer.i.c, conv-uinteger.i.c: Use it instead of
scm_out_of_range.
2004-10-19 15:59:56 +00:00
Marius Vollmer
cd0362604b Include <gmp.h> in numbers.h, not in
numbers.c.
(scm_to_mpz, scm_from_mpz): New.
Thanks to Andreas Vögele!
2004-09-21 00:42:30 +00:00
Marius Vollmer
0bafe73b5d (scm_integer_expt): Do not accept inexact integers. 2004-09-08 14:09:01 +00:00
Kevin Ryde
1e35a229f0 Revert this:
(scm_integer_p): +/-inf is not an integer.
2004-09-08 01:03:06 +00:00
Kevin Ryde
8bddb01ebb (scm_integer_expt): Reject exponent +/-inf.
(scm_integer_p): +/-inf is not an integer.
Bug report by Bill Schottstaedt.
2004-09-07 00:12:45 +00:00
Stefan Jahn
edea856ce5 2004-09-03 Stefan Jahn <stefan@lkcc.org>
* configure.in (isinf): Let configure find the isinf() function
        on MinGW32 systems.

2004-09-03  Stefan Jahn  <stefan@lkcc.org>

        * threads.c (scm_threads_mark_stacks):  Fixed local variable
        definitions.

        * strings.c (scm_i_substring_copy, s_scm_string_append): Fixed
        local variable definitions.

        * stime.c (_POSIX_C_SOURCE):  Do not define this item on
        MinGW32 because it conflicts with its pthread headers.
        (s_scm_mktime): Consider the HAVE_STRUCT_TM_TM_ZONE define.
        (s_scm_strftime): Using scm_from_locale_string() instead of
        scm_makfrom0str().

        * posix.c (s_scm_putenv): Fixed typo in the !HAVE_UNSETENV
        part.

        * numbers.c (scm_init_numbers): Removed check_sanity() call
        inside GUILE_DEBUG.  The function has been removed somewhen...

        * filesys.c (_POSIX_C_SOURCE): Do not define this item on
        MinGW32 because it conflicts with its pthread headers.

2004-09-03  Stefan Jahn  <stefan@lkcc.org>

        * srfi-1.c, srfi-1.h: Renamed any 'lst1' into 'list1' because
        lst1 is a #define on Win32 systems.
2004-09-03 19:45:37 +00:00
Marius Vollmer
b1092b3aaf (scm_inf_p): Synced docstring back from manual. 2004-08-24 16:43:50 +00:00
Marius Vollmer
cc95e00ac6 * strings.h, strings.c: (scm_i_string_chars, scm_i_string_length,
scm_i_string_writable_chars, scm_i_string_stop_writing): New, to
replace SCM_I_STRING_CHARS and SCM_I_STRING_LENGTH.  Updated all
uses.
(scm_i_make_string, scm_c_make_string): New, to replace
scm_allocate_string.  Updated all uses.
(SCM_STRINGP, SCM_STRING_CHARS, SCM_STRING_UCHARS,
SCM_STRING_LENGTH): Deprecated.
(scm_allocate_string, scm_take_str, scm_take0str, scm_mem2string,
scm_str2string, scm_makfrom0str, scm_makfrom0str_opt):
Discouraged.  Replaced all uses with scm_from_locale_string or
similar, as appropriate.
(scm_c_string_length, scm_c_string_ref, scm_c_string_set_x,
scm_c_substring, scm_c_substring_shared, scm_c_substring_copy,
scm_substring_shared, scm_substring_copy): New.

* symbols.c, symbols.h (SCM_SYMBOLP, SCM_SYMBOL_FUNC,
SCM_SET_SYMBOL_FUNC, SCM_SYMBOL_PROPS, SCM_SET_SYMBOL_PROPS,
SCM_SYMBOL_HASH, SCM_SYMBOL_INTERNED_P, scm_mem2symbol,
scm_str2symbol, scm_mem2uninterned_symbol): Discouraged.
(SCM_SYMBOL_LENGTH, SCM_SYMBOL_CHARS, scm_c_symbol2str):
Deprecated.
(SCM_MAKE_SYMBOL_TAG, SCM_SET_SYMBOL_LENGTH, SCM_SET_SYMBOL_CHARS,
SCM_PROP_SLOTS, SCM_SET_PROP_SLOTS): Removed.
(scm_is_symbol, scm_from_locale_symbol, scm_from_locale_symboln):
New, to replace scm_str2symbol and scm_mem2symbol, respectively.
Updated all uses.
(scm_gensym): Generate only the number suffix in the buffer, just
string-append the prefix.
2004-08-19 17:19:44 +00:00
Marius Vollmer
8824ac88f0 * socket.c, rw.c, deprecated.h, validate.h
(SCM_VALIDATE_STRING_COPY): Deprecated.  Replaced all uses with
SCM_VALIDATE_STRING plus SCM_I_STRING_CHARS or
scm_to_locale_string, etc.
(SCM_VALIDATE_SUBSTRING_SPEC_COPY): Deprecated.  Replaced as
above, plus scm_i_get_substring_spec.

* regex-posix.c, read.c, random.c, ramap.c, print.c, numbers.c,
hash.c, gc.c, gc-card.c, convert.i.c, backtrace.c, strop.c,
strorder.c, strports.c, struct.c, symbols.c, unif.c, ports.c: Use
SCM_I_STRING_CHARS, SCM_I_STRING_UCHARS, and SCM_I_STRING_LENGTH
instead of SCM_STRING_CHARS, SCM_STRING_UCHARS, and
SCM_STRING_LENGTH, respectively.  Also, replaced scm_return_first
with more explicit scm_remember_upto_here_1, etc, or introduced
them in the first place.
2004-08-12 17:45:03 +00:00
Marius Vollmer
3101f40f76 (scm_round, scm_truncate): Renamed to scm_c_round and scm_c_truncate;
deprecated versions installed in deprecated.h and deprecated.c.
Changed all uses.
2004-08-09 23:32:14 +00:00
Kevin Ryde
f8a8200bc0 Amend #if and comments for cmp_d and get_d about unreleased gmp, don't
know when or as what version number it will come out.
2004-08-06 01:26:26 +00:00
Marius Vollmer
8507ec804f (scm_complex_p): New, export as "complex?" to Scheme.
(scm_number_p): Export as "number?" to Scheme.
(scm_is_complex, scm_is_number): New.
(scm_c_make_rectangular, scm_c_make_polar): New.
(scm_make_rectangular, scm_make_polar): Use above.
(scm_c_real_part, scm_c_imag_part, scm_c_magnitude, scm_c_angle):
New.
(scm_make_complex): Discouraged by moving to discouraged.h and
discouraged.c.  Replaced all uses with scm_c_make_rectangular.
2004-08-03 17:12:14 +00:00
Marius Vollmer
cba42c9344 * numbers.h. numbers.c (scm_make_ratio): Renamed to
scm_i_make_ratio and made static, replaced uses with scm_divide.
2004-08-03 15:55:42 +00:00
Marius Vollmer
55f26379b3 (scm_is_rational): New.
(scm_i_short2big, scm_i_int2big, scm_i_uint2big, scm_i_size2big,
scm_i_ptrdiff2big, scm_i_long_long2big, scm_i_ulong_long2big):
Removed prototypes.
(scm_make_real, scm_num2dbl, scm_float2num, scm_double2num):
Discouraged by moving to discouraged.h and discouraged.c.
Replaced all uses with scm_from_double.
(scm_num2float, scm_num2double): Discouraged by moving prototype
to discouraged.h and rewriting in terms of scm_to_double.
Replaced all uses with scm_to_double.
(scm_to_double): Do not implement in terms of scm_num2dbl, use
explicit code.
(scm_from_double): Do not implement in terms of scm_make_real, use
explicit code.
2004-08-03 15:03:35 +00:00
Marius Vollmer
c71b07063e * discouraged.h, discouraged.c: New files.
* deprecated.h (SCM_FALSEP, SCM_NFALSEP, SCM_BOOLP, SCM_EQ_P,
SCM_NEGATE_BOOL, SCM_BOOL, SCM_BOOT_NOT): Promoted from being
deprecated to being discouraged by moving to discouraged.h.

* numbers.h, numbers.c, discouraged.h, discouraged.c
(scm_short2num, scm_ushort2num, scm_int2num, scm_uint2num,
scm_long2num, scm_ulong2num, scm_size2num, scm_ptrdiff2num,
scm_num2short, scm_num2ushort, scm_num2int, scm_num2uint,
scm_num2long, scm_num2ulong, scm_num2size, scm_num2ptrdiff,
scm_long_long2num, scm_ulong_long2num, scm_num2long_long,
scm_num2ulong_long): Discouraged by moving to discouraged.h and
discouraged.c and reimplementing in terms of scm_from_* and
scm_to_*.

* numbers.h, numbers.c: Removed GUILE_DEBUG code.
(scm_i_short2big, scm_i_ushort2big, scm_i_int2big, scm_i_uint2big,
scm_i_size2big, scm_i_ptrdiff2big): Removed.
(scm_i_long2big, scm_i_ulong2big): New, explicit definitions.
* conv-integer.i.c, conv-uinteger.i.c: Use them instead of
explicit code.
2004-08-02 15:57:04 +00:00