Kevin Ryde
2a06f79117
(scm_min, scm_max): Correction to big/real and real/big,
...
return inexact as required by r5rs.
2004-03-24 21:53:31 +00:00
Kevin Ryde
240a27d2c5
(guile_ieee_init): Use C99 INFINITY and NAN when
...
available. Test HAVE_DINFINITY and HAVE_DQNAN for those globals, in
particular don't assume "defined (__alpha__) && ! defined (linux)"
means OSF. Remove "SCO" code, which was not really SCO specific and
which John W. Eaton advises should be long past being needed.
2004-02-28 20:01:13 +00:00
Kevin Ryde
dab4e67a0a
(scm_max, scm_min): For one arg, dispatch to generic for
...
complex, same as for two args. (Handle only inum, big, real, frac).
2004-02-21 21:58:30 +00:00
Kevin Ryde
d8b95e27ab
(scm_num_eq_p): For real==frac, complex==frac, frac==real
...
and frac==complex, make an exact comparison rather than converting
with fraction2double.
2004-02-18 00:21:11 +00:00
Kevin Ryde
238ebcef24
(s_bignum): Remove, not used since gmp bignums.
...
Reported by Richard Todd.
2004-01-06 21:55:29 +00:00
Kevin Ryde
a5f0b59988
(scm_less_p): Don't convert frac to float for compares,
...
can give wrong results due to rounding.
2004-01-03 21:38:38 +00:00
Kevin Ryde
084b1d8eec
(scm_less_p): Remove spurious xisnan from frac+big case.
2003-12-02 21:36:39 +00:00
Kevin Ryde
2fa2d87937
(scm_real_part): Return fraction unchanged rather than converting to flonum.
2003-12-02 21:27:13 +00:00
Kevin Ryde
dd5130cadf
(scm_make_ratio): Check for numerator equal to
...
SCM_MOST_NEGATIVE_FIXNUM and bignum denominator the negative of that,
giving integer -1.
2003-12-02 21:21:14 +00:00
Marius Vollmer
535f2a516a
(scm_logand): It's "#b...", not "#\b...".
2003-11-30 00:59:40 +00:00
Kevin Ryde
7f84824269
(scm_bit_extract): Use mpz functions, rearrange inum case
...
to share some shifting.
2003-11-21 00:33:44 +00:00
Kevin Ryde
ae38324d9c
(scm_abs): Allocate a new real only for negatives, as done for bignums.
2003-11-21 00:07:13 +00:00
Kevin Ryde
753ac1e7e1
(scm_integer_expt): Don't mpz_init after scm_i_clonebig or
...
scm_i_mkbig, since they do so already. Don't mpz_clear a bignum SCM,
since gc does this.
2003-11-21 00:03:54 +00:00
Marius Vollmer
c60e130c97
* numbers.c (scm_make_ratio): Rewritten to have a simpler
...
structure. Previously, not all cases with a negative denominator
were covered.
2003-11-19 05:12:08 +00:00
Marius Vollmer
0b0c8e3b4c
* numbers.c (scm_make_ratio): Don't declare divisible_p after
...
statements.
2003-11-19 04:30:40 +00:00
Marius Vollmer
02164269a7
* numbers.c (scm_i_fraction_equalp): Do not treat the return value
...
of scm_equal_p as a C boolean, use SCM_FALSEP. Previously, all
fractions were equal to each other regardless of value. Ooops.
* numbers.c (scm_rationalize): Return an inexact result when given
inexact arguments.
2003-11-19 03:50:26 +00:00
Marius Vollmer
eb927cb95c
* numbers.c (scm_exact_p, scm_inexact_p): Throw error for non-numbers.
2003-11-19 02:38:37 +00:00
Marius Vollmer
d8592269ab
(mem2decimal_from_point): use scm_divide instead of scm_divide2real
...
when forming the fractional part. This allows "#e1.2" to yield 6/5.
2003-11-19 02:19:03 +00:00
Marius Vollmer
f92e85f735
* print.c (scm_iprin1): Handle fractions.
...
* objects.h (scm_class_fraction): New.
* objects.c (scm_class_fraction): New.
(scm_class_of): Handle fractions.
* hash.c (scm_hasher): Handle fractions.
* numbers.c: New code for handling fraction all over the place.
(scm_odd_p, scm_even_p): Handle inexact integers.
(scm_rational_p): New function, same as scm_real_p.
(scm_round_number, scm_truncate_number, scm_ceiling, scm_floor):
New exact functions that replace the inexact 'dsubr'
implementations.
(scm_numerator, scm_denominator): New.
* numbers.h (SCM_NUMP): Recognize fractions.
(SCM_FRACTIONP, SCM_SLOPPY_FRACTIONP, SCM_FRACTION_NUMERATOR,
SCM_FRACTION_DENOMINATOR, SCM_FRACTION_SET_NUMERATOR,
SCM_FRACTION_SET_DENOMINATOR, SCM_FRACTION_REDUCED_BIT,
SCM_FRACTION_REDUCED_SET, SCM_FRACTION_REDUCED_CLEAR,
SCM_FRACTION_REDUCED): New.
(scm_floor, scm_ceiling, scm_truncate_number, scm_round_number):
New prototypes.
(scm_make_ratio, scm_rationalize, scm_numerator, scm_denominator,
scm_rational_p): New prototypes.
(scm_i_dbl2num, scm_i_fraction2double, scm_i_fraction_equalp,
scm_i_print_fraction): New prototypes.
* goops.c (create_standard_classes): Create "<fraction>" class.
* gc-mark.c (scm_gc_mark_dependencies): Handle fractions.
* gc-card.c (scm_i_sweep_card): Include scm_tc16_fraction as a
case in the switch, but do nothing for now.
* eval.c (SCM_CEVAL, SCM_APPLY, call_dsubr_1): Convert fractions
to doubles when calling 'dsubr' functions.
* eq.c (scm_eqv_p, scm_equal_p): Handle fractions.
2003-11-18 19:59:53 +00:00
Kevin Ryde
089c9a5909
(scm_i_big2dbl): Rewrite, carefully rounding to "closest"
...
in accordance with R5RS, which just mpz_get_d doesn't really give.
2003-10-19 00:32:25 +00:00
Kevin Ryde
32f19569bc
(scm_ash): Revise docstring as per recent update to manual.
2003-10-19 00:27:00 +00:00
Kevin Ryde
2be24db4d7
(scm_inexact_to_exact): Don't depend on what double->long
...
cast gives for values bigger than a long, or for nan or inf.
2003-10-09 00:38:51 +00:00
Dirk Herrmann
534c55a97d
This set of patches introduces a new tc7 code scm_tc7_number for
...
numbers. Bignums, reals and complex numbers are turned from smobs
into subtypes of scm_tc7_number.
* tags.h (scm_tc7_number): New.
* eq.c (scm_equal_p), eval.c (SCM_CEVAL), evalext.c
(scm_self_evaluating_p), gc-card.c (scm_i_sweep_card), gc-mark.c
(scm_gc_mark_dependencies), goops.c (create_smob_classes), hash.c
(scm_hasher), numbers.c, numbers.h (SCM_NUMP), objects.c
(scm_class_of), print.c (scm_iprin1), smob.c
(scm_smob_prehistory): Don't handle bignums, reals and complex
numbers as subtypes of scm_tc7_smob any more.
* numbers.h, tags.h (scm_tc16_big, scm_tc16_real,
scm_tc16_complex): Moved definitions from tags.h to numbers.h.
2003-09-18 20:55:40 +00:00
Dirk Herrmann
29c4382afd
* numbers.c (scm_make_complex), gc-card.c (scm_i_sweep_card): Use
...
sizeof (scm_t_complex) to determine the memory size of the
malloc'd area for complex numbers.
2003-09-18 20:18:17 +00:00
Dirk Herrmann
47ae1f0eca
* libguile/numbers.c (scm_bigequal): Fixed.
...
* test-suite/tests/numbers.test (equal?): Added tests.
* test-suite/tests/numbers.test (=): Fixed and added some bignum
related tests.
2003-09-17 21:03:26 +00:00
Kevin Ryde
4d814788fc
(scm_lognot): Correction to docstring, ones-complement not 2s-complement.
2003-09-02 23:00:28 +00:00
Kevin Ryde
f9811f9f2e
(scm_lognot): Rewrite using ~ and mpz_com, for directness
...
and to have non-integer types rejected as per other logical funcs.
2003-08-30 00:04:42 +00:00
Kevin Ryde
708f22c6af
(scm_difference): Correction to bignum - negative inum.
2003-08-22 01:17:48 +00:00
Marius Vollmer
570b6821e3
* __scm.h (SCM_C_INLINE_KEYWORD): New.
...
* numbers.c: Use it in place of SCM_C_INLINE so that the code
compiles when SCM_C_INLINE is undefined.
2003-07-27 13:34:32 +00:00
Kevin Ryde
c8ae173e8a
(scm_angle): Use scm_flo0 for non-negative inum, bignum and real.
2003-07-24 01:03:40 +00:00
Kevin Ryde
7650633547
(scm_product): In complex * bignum, correction to
...
REAL/IMAG fetch, x is the complex, not y.
2003-07-17 23:38:34 +00:00
Mikael Djurfeldt
0aacf84ee6
(scm_odd_p, scm_even_p): Bugfix: Treat result of
...
scm_inf_p test as Scheme values.
(scm_sum): Bugfix: Normalize bignum created from a negative bignum
and a positive inum.
Use GNU indentation style.
2003-07-13 16:13:57 +00:00
Kevin Ryde
6efadd7cb6
(scm_make_polar): Use sincos, when available.
...
(scm_magnitude): Use hypot.
2003-07-08 00:27:03 +00:00
Kevin Ryde
fa60559018
(_GNU_SOURCE): #define, to get C99 things.
...
(scm_asinh, scm_acosh, scm_atanh, scm_truncate, $asinh, $acosh,
$atanh, truncate): Use C library asinh, acosh, atanh and trunc, when
available.
(scm_inexact_to_exact): Expand isfinite to its definition !isinf.
(isfinite): Remove, conflicts with C99 isfinite().
2003-06-21 00:12:51 +00:00
Kevin Ryde
e06beeadda
(scm_max, scm_min): For inum, bignum and real, if other
...
operand is NaN, then return NaN. Also avoid passing NaN to mpz_cmp_d.
2003-06-04 16:09:38 +00:00
Dirk Herrmann
14b18ed6f5
This set of patches separates the representation of the cxr family
...
of functions (car, cdr etc.) from the dsubr family of functions
(i. e. functions that take a double precision floating point
argument). Further, the algorithm for handling the cxr function
is improved.
* eval.c (SCM_CEVAL, SCM_APPLY, scm_trampoline_1), numbers.c
(scm_asinh, scm_acosh, scm_atanh, scm_truncate, scm_round, floor,
ceil, sqrt, fabs, exp, log, sin, cos, tan, asin, acos, atan, sinh,
cosh, tanh), objects.c (scm_class_of), procprop.c
(scm_i_procedure_arity), ramap.c (scm_array_map_x), tags.h
(scm_tc7_dsubr, scm_tcs_subrs): Introduce scm_tc7_dsubr as new
typecode for the dsubr family of functions.
* ramap.c (ramap_cxr, ramap_dsubr): Renamed ramap_cxr to
ramap_dsubr.
* eval.c (SCM_CEVAL, SCM_APPLY, call_cxr_1), pairs.c
(scm_init_pairs): Make use of the (now usable) second cell element
of a scm_tc7_cxr function to implement the cxr family of functions
more efficiently.
2003-06-01 13:58:42 +00:00
Kevin Ryde
713a425913
(z_negative_one): New variable.
...
(scm_init_numbers): Initialize it.
(scm_logcount): Use it and mpz_hamdist to count zeros for negatives.
2003-05-30 00:23:11 +00:00
Kevin Ryde
b127c712ea
(xmpz_cmp_d): New macro, handling infs if gmp doesn't.
...
(scm_num_eq_p, scm_less_p, scm_max, scm_min): Use it.
2003-05-12 23:16:43 +00:00
Kevin Ryde
8c5b0afcbf
(scm_gcd): In bignum/inum, don't pass yy==0 to mpz_gcd_ui
...
since we're only using the ulong return value, and x might not fit.
2003-05-10 00:20:05 +00:00
Kevin Ryde
2c57607ca8
(scm_integer_length): On negative bignums, adjust
...
mpz_sizeinbase to account for it looking at absolute value where we
want ones-complement.
2003-05-10 00:05:51 +00:00
Kevin Ryde
2b031f4f65
(scm_num_eq_p, scm_less_p): Don't pass NaN to mpz_cmp_d.
2003-05-09 23:14:35 +00:00
Kevin Ryde
c78b590e56
(scm_logcount): Use mpz_com, not mpz_neg.
2003-05-05 23:01:30 +00:00
Kevin Ryde
9c4443d38c
(scm_difference): In inum - bignum, handle negative inum.
2003-05-05 22:55:46 +00:00
Marius Vollmer
9dd023e147
Doc fix for the usage of num2intergral.
2003-05-03 23:19:51 +00:00
Dirk Herrmann
aec16f9972
* numbers.c (scm_logtest): Fixed argument bug in the call to
...
mpz_and, which showed up when compiling with SCM_DEBUG defined.
2003-04-20 08:55:50 +00:00
Rob Browning
1c35cb199f
* numbers.c (scm_integer_expt): fix case where we were declaring
...
vars in the middle of a statement block. Thanks to Thamer
Al-Harbash.
2003-04-17 22:15:37 +00:00
Rob Browning
b4fb7de868
* numbers.c (PTRDIFF_MIN): use SCM_CHAR_BIT.
2003-04-16 19:44:02 +00:00
Rob Browning
876173478e
*** empty log message ***
2003-04-07 17:36:17 +00:00
Marius Vollmer
73be1d9e8e
Changed license terms to the plain LGPL thru-out.
2003-04-05 19:15:35 +00:00
Rob Browning
ca46fb9018
* numbers.c: rewrite *many* functions to handle GMP bignums.
2003-04-04 21:49:44 +00:00