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
Marius Vollmer
bfd7932e66
* conv-integer.i.c, conv-uinteger.i.c: New files, used to generate
...
the functions below.
* numbers.c, numbers.h (scm_to_int8, scm_to_uint8, scm_to_int16,
scm_to_uint16, scm_to_int32, scm_to_uint32, scm_to_int64,
scm_to_uint64, scm_from_int8, scm_from_uint8, scm_from_int16,
scm_from_uint16, scm_from_int32, scm_from_uint32, scm_from_int64,
scm_from_uint64): Turned from macros into proper functions.
(scm_to_signed_integer, scm_to_unsigned_integer,
scm_from_signed_integer, scm_from_unsigned_integer): Generate via
conv-integer.i.c and conv-uinteger.i.c, as well.
2004-07-29 13:42:50 +00:00
Marius Vollmer
bc36d0502b
* tags.h, deprecated.h (SCM_EQ_P): Deprecated by moving it into
...
deprecated.h. Replaced all uses with scm_is_eq.
2004-07-27 15:41:49 +00:00
Marius Vollmer
e11e83f3d9
* deprecated.h, deprecated.c, numbers.h (SCM_INUMP, SCM_NINUMP,
...
SCM_INUM): Deprecated by reenaming them to SCM_I_INUMP, SCM_I_NINUMP
and SCM_I_INUM, respectively and adding deprecated versions to
deprecated.h and deprecated.c. Changed all uses to either use the
SCM_I_ variants or scm_is_*, scm_to_*, or scm_from_*, as appropriate.
2004-07-23 15:43:02 +00:00
Marius Vollmer
5efd3c7d68
(scm_to_signed_integer, scm_to_unsigned_integer): dot
...
not accept inexact integers.
* validate.h, deprecated.h (SCM_VALIDATE_INUM, SCM_VALIDATE_INUM_COPY,
SCM_VALIDATE_BIGINT, SCM_VALIDATE_INUM_MIN,
SCM_VALIDATE_INUM_MIN_COPY,
SCM_VALIDATE_INUM_MIN_DEF_COPY,SCM_VALIDATE_INUM_DEF,
SCM_VALIDATE_INUM_DEF_COPY, SCM_VALIDATE_INUM_RANGE,
SCM_VALIDATE_INUM_RANGE_COPY): Deprecated because they make the
fixnum/bignum distinction visible. Changed all uses to scm_to_size_t
or similar.
2004-07-10 13:55:04 +00:00
Marius Vollmer
d956fa6f91
(scm_is_signed_integer, scm_is_unsigned_integer):
...
Rewritten using the same logic as scm_to_signed_integer and
scm_to_unsigned_integer, respectively, which is better(tm). Also,
use CHAR_BIT instead of hardcoding 8.
(LLONG_MIN, LLONG_MAX, ULLONG_MAX): Removed and used
SCM_I_LLONG_MIN etc. instead.
* numbers.h (SCM_MAKINUM, SCM_I_MAKINUM): Renamed SCM_MAKINUM to
SCM_I_MAKINUM and changed all uses.
2004-07-08 15:54:05 +00:00
Marius Vollmer
73e4de09b9
(scm_is_integer, scm_is_signed_integer, scm_is_unsigned_integer,
...
scm_to_signed_integer, scm_to_unsigned_integer, scm_to_schar,
scm_to_uchar, scm_to_char, scm_to_short, scm_to_ushort, scm_to_long,
scm_to_ulong, scm_to_size_t, scm_to_ssize_t, scm_from_schar,
scm_from_uchar, scm_from_char, scm_from_short, scm_from_ushort,
scm_from_int, scm_from_uint, scm_from_long, scm_from_ulong,
scm_from_size_t, scm_from_ssize_t, scm_is_real, scm_to_double,
scm_from_double): New.
* deprecated.h, boolean.h (SCM_FALSEP, SCM_NFALSEP, SCM_BOOL,
SCM_NEGATE_BOOL, SCM_BOOLP): Deprecated by moving into "deprecated.h".
Replaced all uses with scm_is_false, scm_is_true, scm_from_bool, and
scm_is_bool, respectively.
2004-07-06 10:23:30 +00:00
Kevin Ryde
faff1f2fda
(trunc): Remove #define to scm_truncate when the C library
...
doesn't provide trunc. This was for when `truncate' was done as a
scm_tc7_dsubr, no longer required.
2004-05-18 23:45:34 +00:00
Kevin Ryde
bae30667b0
(scm_round_number): For inum and big, just return x. For
...
real, use scm_round for 2^54-1 etc problems covered there.
2004-05-18 23:43:28 +00:00
Marius Vollmer
0b799eeab6
(FLOBUFLEN): Increase so that radix 2 strings will fit.
...
(fx): Removed.
(scm_dblprec, fx_per_radix, init_dblprec, init_fx_radix,
number_chars): New, to support variable radices.
(idbl2str): Use above instead of the old base-10 only tables.
(iflo2str): Pass on new RADIX argument to idbl2str.
(scm_number_to_string): Pass radix to iflo2str.
(scm_print_real, scm_print_complex): Explicitly pass radix 10 to
iflo2str.
(scm_init_numbers): Call init_dblprec and init_fx_radix for all
possible radices.
2004-05-10 20:35:39 +00:00
Kevin Ryde
20fcc8ed86
More of:
...
(scm_logbit_p): Correction to test above the end of an
inum. Reported by Jan Konecny.
2004-05-09 22:46:17 +00:00
Kevin Ryde
0d75f6d819
(scm_logbit_p): Correction to test above the end of an
...
inum. Reported by Jan Konecny.
2004-05-09 22:33:29 +00:00
Kevin Ryde
71df73ac43
numbers.c (XDIGIT2UINT,
...
mem2uinteger, mem2decimal_from_point, mem2ureal): Cast char to int for
ctype.h tests, to avoid warnings from gcc on HP-UX about char as array
subscript. Reported by Andreas Vögele.
Also cast through unsigned char to avoid passing negatives to those
macros if input contains 8-bit values.
2004-04-27 23:16:17 +00:00
Kevin Ryde
857ae6afd3
(scm_bit_extract): Use min instead of MIN.
...
(MIN): Remove, this conflicts with similar macro defined by limits.h
on HP-UX. Reported by Andreas Vögele.
2004-04-27 22:19:41 +00:00
Kevin Ryde
d77ad56065
(scm_bit_extract): Use SCM_SRS for signed right shift.
2004-04-22 01:21:39 +00:00
Kevin Ryde
6187f48b1a
(scm_round): Test for x already an integer, to avoid bad
...
rounding in x+0.5 when x is a big value already an integer. In
certain hardware rounding cases x+0.5 can give an adjacent integer,
leading to that as the result, when we really just wanted x itself.
2004-04-21 23:15:55 +00:00
Kevin Ryde
b6f8f763db
(scm_max, scm_min): For big/real, use SCM_SWAP rather than
...
explicit swapping code.
2004-04-17 21:58:23 +00:00
Kevin Ryde
0bff4dce95
(scm_gcd): For inum/big, use mpz_gcd_ui by sharing code with big/inum.
2004-04-15 01:45:12 +00:00
Kevin Ryde
a98ce90708
(xisinf): Add a comment about solaris 7 lacking isinf.
2004-04-15 01:24:00 +00:00
Kevin Ryde
e4bc5d6ca7
(scm_max, scm_min): For inum/frac, frac/inum, big/frac,
...
frac/big and frac/frac, use scm_less_p for exact comparison.
2004-04-15 00:44:19 +00:00
Kevin Ryde
e7644cb292
(scm_ash): Remove stray "}" in docstring.
2004-04-06 00:17:41 +00:00
Kevin Ryde
3271a325c8
(scm_make_ratio): For inum/bignum integer detection, use
...
x==SCM_MOST_NEGATIVE_FIXNUM explicitly, for clarity and to avoid
calling mpz_cmp_ui in most cases.
2004-04-05 23:31:20 +00:00
Kevin Ryde
4dc09ee4ff
(scm_quotient, scm_remainder): In inum/big, use mpz_cmp_ui
...
for big == abs(most-negative-fixnum) special case.
(abs_most_negative_fixnum): Remove, no longer used.
2004-04-05 22:48:05 +00:00
Kevin Ryde
1fff961089
(scm_modulo): For inum/big and big/big, remove test of
...
big==0 since that never occurs.
2004-03-25 21:56:27 +00:00
Kevin Ryde
d885e204fd
(scm_modulo_expt): Renamed from
...
scm_modular_expt, matching scheme level name `modulo-expt'.
2004-03-25 21:55:20 +00:00
Kevin Ryde
b7b8c57576
(scm_modular_expt): Return a negative remainder for a
...
negative divisor, the same as `modulo' does.
2004-03-25 21:51:39 +00:00
Kevin Ryde
518b750845
2004-03-26 Eric Hanchrow <offby1@blarg.net>
...
* numbers.c, numbers.h (scm_modular_expt): New function.
2004-03-25 21:35:53 +00:00
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