1996-07-25 22:56:11 +00:00
|
|
|
|
/* classes: h_files */
|
|
|
|
|
|
|
2001-07-30 19:35:15 +00:00
|
|
|
|
#ifndef SCM_NUMBERS_H
|
|
|
|
|
|
#define SCM_NUMBERS_H
|
2001-08-31 12:13:50 +00:00
|
|
|
|
|
2004-03-25 21:38:59 +00:00
|
|
|
|
/* Copyright (C) 1995,1996,1998,2000,2001,2002,2003,2004 Free Software Foundation, Inc.
|
2001-08-31 12:13:50 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2001-08-31 12:13:50 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
1996-07-25 22:56:11 +00:00
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
|
* Lesser General Public License for more details.
|
2001-08-31 12:13:50 +00:00
|
|
|
|
*
|
2003-04-05 19:15:35 +00:00
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
|
*/
|
1999-12-16 03:46:42 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
* alist.h, append.h, arbiters.h, async.h, boolean.h, chars.h,
continuations.h, debug.h, dynwind.h, error.h, eval.h, fdsocket.h,
feature.h, filesys.h, fports.h, gc.h, gdbint.h, genio.h, gsubr.h,
hash.h, init.h, ioext.h, kw.h, list.h, markers.h, marksweep.h,
mbstrings.h, numbers.h, objprop.h, options.h, pairs.h, ports.h,
posix.h, print.h, procprop.h, procs.h, ramap.h, read.h, root.h,
sequences.h, smob.h, socket.h, srcprop.h, stackchk.h, stime.h,
strings.h, strop.h, strorder.h, strports.h, struct.h, symbols.h,
tag.h, throw.h, unif.h, variable.h, vectors.h, version.h,
vports.h, weaks.h: #include "libguile/__scm.h", not
<libguile/__scm.h>. This allows 'gcc -MM' to determine which
dependencies are within libguile properly.
1996-09-05 21:19:08 +00:00
|
|
|
|
#include "libguile/__scm.h"
|
1999-01-10 07:38:05 +00:00
|
|
|
|
#include "libguile/print.h"
|
|
|
|
|
|
|
2003-03-27 20:09:18 +00:00
|
|
|
|
#if SCM_HAVE_FLOATINGPOINT_H
|
|
|
|
|
|
# include <floatingpoint.h>
|
2002-05-06 22:27:42 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
2003-03-27 20:09:18 +00:00
|
|
|
|
#if SCM_HAVE_IEEEFP_H
|
|
|
|
|
|
# include <ieeefp.h>
|
2002-05-06 22:27:42 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
|
2003-03-27 20:09:18 +00:00
|
|
|
|
#if SCM_HAVE_NAN_H
|
|
|
|
|
|
# if defined (SCO)
|
|
|
|
|
|
# define _IEEE 1
|
|
|
|
|
|
# endif
|
|
|
|
|
|
# include <nan.h>
|
|
|
|
|
|
# if defined (SCO)
|
|
|
|
|
|
# undef _IEEE
|
|
|
|
|
|
# endif
|
|
|
|
|
|
#endif /* SCM_HAVE_NAN_H */
|
2002-05-06 22:27:42 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2001-10-05 17:43:49 +00:00
|
|
|
|
/* Immediate Numbers, also known as fixnums
|
1996-07-25 22:56:11 +00:00
|
|
|
|
*
|
2001-10-05 17:43:49 +00:00
|
|
|
|
* Inums are exact integer data that fits within an SCM word. */
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2001-10-06 20:48:27 +00:00
|
|
|
|
/* SCM_T_SIGNED_MAX is (- (expt 2 n) 1),
|
|
|
|
|
|
* SCM_MOST_POSITIVE_FIXNUM should be (- (expt 2 (- n 2)) 1)
|
|
|
|
|
|
* which is the same as (/ (- (expt 2 n) 4) 4)
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2001-10-06 19:58:02 +00:00
|
|
|
|
#define SCM_I_FIXNUM_BIT (SCM_LONG_BIT - 2)
|
2001-10-06 20:48:27 +00:00
|
|
|
|
#define SCM_MOST_POSITIVE_FIXNUM ((SCM_T_SIGNED_BITS_MAX-3)/4)
|
2001-10-06 19:58:02 +00:00
|
|
|
|
#define SCM_MOST_NEGATIVE_FIXNUM (-SCM_MOST_POSITIVE_FIXNUM-1)
|
2001-01-18 13:35:45 +00:00
|
|
|
|
|
2000-05-16 12:11:08 +00:00
|
|
|
|
/* SCM_SRS is signed right shift */
|
|
|
|
|
|
#if (-1 == (((-1) << 2) + 2) >> 2)
|
2001-10-05 17:43:49 +00:00
|
|
|
|
# define SCM_SRS(x, y) ((x) >> (y))
|
1996-07-25 22:56:11 +00:00
|
|
|
|
#else
|
2001-10-05 17:43:49 +00:00
|
|
|
|
# define SCM_SRS(x, y) ((x) < 0 ? ~((~(x)) >> (y)) : ((x) >> (y)))
|
2000-05-16 12:11:08 +00:00
|
|
|
|
#endif /* (-1 == (((-1) << 2) + 2) >> 2) */
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2000-05-16 12:11:08 +00:00
|
|
|
|
#define SCM_INUMP(x) (2 & SCM_UNPACK (x))
|
|
|
|
|
|
#define SCM_NINUMP(x) (!SCM_INUMP (x))
|
2003-09-04 20:04:30 +00:00
|
|
|
|
#define SCM_MAKINUM(x) \
|
|
|
|
|
|
(SCM_PACK ((((scm_t_signed_bits) (x)) << 2) + scm_tc2_int))
|
2001-10-05 17:43:49 +00:00
|
|
|
|
#define SCM_INUM(x) (SCM_SRS ((scm_t_signed_bits) SCM_UNPACK (x), 2))
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2000-05-25 13:53:49 +00:00
|
|
|
|
/* SCM_FIXABLE is true if its long argument can be encoded in an SCM_INUM. */
|
|
|
|
|
|
#define SCM_POSFIXABLE(n) ((n) <= SCM_MOST_POSITIVE_FIXNUM)
|
|
|
|
|
|
#define SCM_NEGFIXABLE(n) ((n) >= SCM_MOST_NEGATIVE_FIXNUM)
|
2001-10-05 17:43:49 +00:00
|
|
|
|
#define SCM_FIXABLE(n) (SCM_POSFIXABLE (n) && SCM_NEGFIXABLE (n))
|
2000-05-25 13:53:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
2000-05-16 12:11:08 +00:00
|
|
|
|
/* A name for 0. */
|
2000-05-04 08:07:18 +00:00
|
|
|
|
#define SCM_INUM0 (SCM_MAKINUM (0))
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2001-10-06 20:48:27 +00:00
|
|
|
|
/* SCM_MAXEXP is the maximum double precision exponent
|
* __scm.h eq.c, eval.c, gc.c, hc.h, gh_data, hash.c, numbers.c,
numbers.h, objects.c, ramap.c, random.c, unif.c, unif.h: Extensive
rewrite of handling of real and complex numbers.
(SCM_FLOATS, SCM_SINGLES): These #ifdef conditionals have been
removed along with the support for floats. (Float vectors are
still supported.)
* numbers.h (SCM_BIGSIGN): Sign moved to bit 16.
(scm_makdbl): Deprecated.
(SCM_NEWREAL, SCM_NEWCOMPLEX): New macros.
(SCM_SINGP): Deprecated.
(SCM_FLO): Removed.
(SCM_INEXP, SCM_CPLXP): Deprecated.
(SCM_INEXACTP, SCM_COMPLEXP): New macros.
(SCM_COMPLEX_REAL, SCM_COMPLEX_IMAG): Renamed from
SCM_REAL, SCM_IMAG (and now only valid for complex numbers).
(SCM_REAL, SCM_IMAG): New, *deprecated*, selectors which work both
for doubles and complex numbers.
(SCM_REAL_VALUE): New selector for doubles.
(scm_double_t, scm_complex_t): New types.
(scm_dbl): Removed.
* numbers.h (struct scm_dbl): changed to represent a double cell,
with the number in the second half.
(struct scm_cplx): new, represents a complex number as a triple
cell.
2000-03-14 06:41:25 +00:00
|
|
|
|
* SCM_FLTMAX is less than or scm_equal the largest single precision float
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2003-03-27 20:09:18 +00:00
|
|
|
|
#if SCM_HAVE_STDC_HEADERS
|
|
|
|
|
|
# ifndef GO32
|
2003-05-30 09:39:34 +00:00
|
|
|
|
# include <float.h>
|
|
|
|
|
|
# ifdef __MINGW32__
|
|
|
|
|
|
# define copysign _copysign
|
|
|
|
|
|
# define isnan _isnan
|
|
|
|
|
|
# define finite _finite
|
|
|
|
|
|
# endif /* __MINGW32__ */
|
2003-03-27 20:09:18 +00:00
|
|
|
|
# endif /* ndef GO32 */
|
* __scm.h eq.c, eval.c, gc.c, hc.h, gh_data, hash.c, numbers.c,
numbers.h, objects.c, ramap.c, random.c, unif.c, unif.h: Extensive
rewrite of handling of real and complex numbers.
(SCM_FLOATS, SCM_SINGLES): These #ifdef conditionals have been
removed along with the support for floats. (Float vectors are
still supported.)
* numbers.h (SCM_BIGSIGN): Sign moved to bit 16.
(scm_makdbl): Deprecated.
(SCM_NEWREAL, SCM_NEWCOMPLEX): New macros.
(SCM_SINGP): Deprecated.
(SCM_FLO): Removed.
(SCM_INEXP, SCM_CPLXP): Deprecated.
(SCM_INEXACTP, SCM_COMPLEXP): New macros.
(SCM_COMPLEX_REAL, SCM_COMPLEX_IMAG): Renamed from
SCM_REAL, SCM_IMAG (and now only valid for complex numbers).
(SCM_REAL, SCM_IMAG): New, *deprecated*, selectors which work both
for doubles and complex numbers.
(SCM_REAL_VALUE): New selector for doubles.
(scm_double_t, scm_complex_t): New types.
(scm_dbl): Removed.
* numbers.h (struct scm_dbl): changed to represent a double cell,
with the number in the second half.
(struct scm_cplx): new, represents a complex number as a triple
cell.
2000-03-14 06:41:25 +00:00
|
|
|
|
#endif /* def STDC_HEADERS */
|
2003-03-27 20:09:18 +00:00
|
|
|
|
|
* __scm.h eq.c, eval.c, gc.c, hc.h, gh_data, hash.c, numbers.c,
numbers.h, objects.c, ramap.c, random.c, unif.c, unif.h: Extensive
rewrite of handling of real and complex numbers.
(SCM_FLOATS, SCM_SINGLES): These #ifdef conditionals have been
removed along with the support for floats. (Float vectors are
still supported.)
* numbers.h (SCM_BIGSIGN): Sign moved to bit 16.
(scm_makdbl): Deprecated.
(SCM_NEWREAL, SCM_NEWCOMPLEX): New macros.
(SCM_SINGP): Deprecated.
(SCM_FLO): Removed.
(SCM_INEXP, SCM_CPLXP): Deprecated.
(SCM_INEXACTP, SCM_COMPLEXP): New macros.
(SCM_COMPLEX_REAL, SCM_COMPLEX_IMAG): Renamed from
SCM_REAL, SCM_IMAG (and now only valid for complex numbers).
(SCM_REAL, SCM_IMAG): New, *deprecated*, selectors which work both
for doubles and complex numbers.
(SCM_REAL_VALUE): New selector for doubles.
(scm_double_t, scm_complex_t): New types.
(scm_dbl): Removed.
* numbers.h (struct scm_dbl): changed to represent a double cell,
with the number in the second half.
(struct scm_cplx): new, represents a complex number as a triple
cell.
2000-03-14 06:41:25 +00:00
|
|
|
|
#ifdef DBL_MAX_10_EXP
|
2003-03-27 20:09:18 +00:00
|
|
|
|
# define SCM_MAXEXP DBL_MAX_10_EXP
|
* __scm.h eq.c, eval.c, gc.c, hc.h, gh_data, hash.c, numbers.c,
numbers.h, objects.c, ramap.c, random.c, unif.c, unif.h: Extensive
rewrite of handling of real and complex numbers.
(SCM_FLOATS, SCM_SINGLES): These #ifdef conditionals have been
removed along with the support for floats. (Float vectors are
still supported.)
* numbers.h (SCM_BIGSIGN): Sign moved to bit 16.
(scm_makdbl): Deprecated.
(SCM_NEWREAL, SCM_NEWCOMPLEX): New macros.
(SCM_SINGP): Deprecated.
(SCM_FLO): Removed.
(SCM_INEXP, SCM_CPLXP): Deprecated.
(SCM_INEXACTP, SCM_COMPLEXP): New macros.
(SCM_COMPLEX_REAL, SCM_COMPLEX_IMAG): Renamed from
SCM_REAL, SCM_IMAG (and now only valid for complex numbers).
(SCM_REAL, SCM_IMAG): New, *deprecated*, selectors which work both
for doubles and complex numbers.
(SCM_REAL_VALUE): New selector for doubles.
(scm_double_t, scm_complex_t): New types.
(scm_dbl): Removed.
* numbers.h (struct scm_dbl): changed to represent a double cell,
with the number in the second half.
(struct scm_cplx): new, represents a complex number as a triple
cell.
2000-03-14 06:41:25 +00:00
|
|
|
|
#else
|
2003-03-27 20:09:18 +00:00
|
|
|
|
# define SCM_MAXEXP 308 /* IEEE doubles */
|
* __scm.h eq.c, eval.c, gc.c, hc.h, gh_data, hash.c, numbers.c,
numbers.h, objects.c, ramap.c, random.c, unif.c, unif.h: Extensive
rewrite of handling of real and complex numbers.
(SCM_FLOATS, SCM_SINGLES): These #ifdef conditionals have been
removed along with the support for floats. (Float vectors are
still supported.)
* numbers.h (SCM_BIGSIGN): Sign moved to bit 16.
(scm_makdbl): Deprecated.
(SCM_NEWREAL, SCM_NEWCOMPLEX): New macros.
(SCM_SINGP): Deprecated.
(SCM_FLO): Removed.
(SCM_INEXP, SCM_CPLXP): Deprecated.
(SCM_INEXACTP, SCM_COMPLEXP): New macros.
(SCM_COMPLEX_REAL, SCM_COMPLEX_IMAG): Renamed from
SCM_REAL, SCM_IMAG (and now only valid for complex numbers).
(SCM_REAL, SCM_IMAG): New, *deprecated*, selectors which work both
for doubles and complex numbers.
(SCM_REAL_VALUE): New selector for doubles.
(scm_double_t, scm_complex_t): New types.
(scm_dbl): Removed.
* numbers.h (struct scm_dbl): changed to represent a double cell,
with the number in the second half.
(struct scm_cplx): new, represents a complex number as a triple
cell.
2000-03-14 06:41:25 +00:00
|
|
|
|
#endif /* def DBL_MAX_10_EXP */
|
2003-03-27 20:09:18 +00:00
|
|
|
|
|
* __scm.h eq.c, eval.c, gc.c, hc.h, gh_data, hash.c, numbers.c,
numbers.h, objects.c, ramap.c, random.c, unif.c, unif.h: Extensive
rewrite of handling of real and complex numbers.
(SCM_FLOATS, SCM_SINGLES): These #ifdef conditionals have been
removed along with the support for floats. (Float vectors are
still supported.)
* numbers.h (SCM_BIGSIGN): Sign moved to bit 16.
(scm_makdbl): Deprecated.
(SCM_NEWREAL, SCM_NEWCOMPLEX): New macros.
(SCM_SINGP): Deprecated.
(SCM_FLO): Removed.
(SCM_INEXP, SCM_CPLXP): Deprecated.
(SCM_INEXACTP, SCM_COMPLEXP): New macros.
(SCM_COMPLEX_REAL, SCM_COMPLEX_IMAG): Renamed from
SCM_REAL, SCM_IMAG (and now only valid for complex numbers).
(SCM_REAL, SCM_IMAG): New, *deprecated*, selectors which work both
for doubles and complex numbers.
(SCM_REAL_VALUE): New selector for doubles.
(scm_double_t, scm_complex_t): New types.
(scm_dbl): Removed.
* numbers.h (struct scm_dbl): changed to represent a double cell,
with the number in the second half.
(struct scm_cplx): new, represents a complex number as a triple
cell.
2000-03-14 06:41:25 +00:00
|
|
|
|
#ifdef FLT_MAX
|
2003-03-27 20:09:18 +00:00
|
|
|
|
# define SCM_FLTMAX FLT_MAX
|
* __scm.h eq.c, eval.c, gc.c, hc.h, gh_data, hash.c, numbers.c,
numbers.h, objects.c, ramap.c, random.c, unif.c, unif.h: Extensive
rewrite of handling of real and complex numbers.
(SCM_FLOATS, SCM_SINGLES): These #ifdef conditionals have been
removed along with the support for floats. (Float vectors are
still supported.)
* numbers.h (SCM_BIGSIGN): Sign moved to bit 16.
(scm_makdbl): Deprecated.
(SCM_NEWREAL, SCM_NEWCOMPLEX): New macros.
(SCM_SINGP): Deprecated.
(SCM_FLO): Removed.
(SCM_INEXP, SCM_CPLXP): Deprecated.
(SCM_INEXACTP, SCM_COMPLEXP): New macros.
(SCM_COMPLEX_REAL, SCM_COMPLEX_IMAG): Renamed from
SCM_REAL, SCM_IMAG (and now only valid for complex numbers).
(SCM_REAL, SCM_IMAG): New, *deprecated*, selectors which work both
for doubles and complex numbers.
(SCM_REAL_VALUE): New selector for doubles.
(scm_double_t, scm_complex_t): New types.
(scm_dbl): Removed.
* numbers.h (struct scm_dbl): changed to represent a double cell,
with the number in the second half.
(struct scm_cplx): new, represents a complex number as a triple
cell.
2000-03-14 06:41:25 +00:00
|
|
|
|
#else
|
2003-03-27 20:09:18 +00:00
|
|
|
|
# define SCM_FLTMAX 1e+23
|
* __scm.h eq.c, eval.c, gc.c, hc.h, gh_data, hash.c, numbers.c,
numbers.h, objects.c, ramap.c, random.c, unif.c, unif.h: Extensive
rewrite of handling of real and complex numbers.
(SCM_FLOATS, SCM_SINGLES): These #ifdef conditionals have been
removed along with the support for floats. (Float vectors are
still supported.)
* numbers.h (SCM_BIGSIGN): Sign moved to bit 16.
(scm_makdbl): Deprecated.
(SCM_NEWREAL, SCM_NEWCOMPLEX): New macros.
(SCM_SINGP): Deprecated.
(SCM_FLO): Removed.
(SCM_INEXP, SCM_CPLXP): Deprecated.
(SCM_INEXACTP, SCM_COMPLEXP): New macros.
(SCM_COMPLEX_REAL, SCM_COMPLEX_IMAG): Renamed from
SCM_REAL, SCM_IMAG (and now only valid for complex numbers).
(SCM_REAL, SCM_IMAG): New, *deprecated*, selectors which work both
for doubles and complex numbers.
(SCM_REAL_VALUE): New selector for doubles.
(scm_double_t, scm_complex_t): New types.
(scm_dbl): Removed.
* numbers.h (struct scm_dbl): changed to represent a double cell,
with the number in the second half.
(struct scm_cplx): new, represents a complex number as a triple
cell.
2000-03-14 06:41:25 +00:00
|
|
|
|
#endif /* def FLT_MAX */
|
|
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
/* SCM_INTBUFLEN is the maximum number of characters neccessary for the
|
|
|
|
|
|
* printed or scm_string representation of an exact immediate.
|
|
|
|
|
|
*/
|
2001-05-26 20:51:22 +00:00
|
|
|
|
#define SCM_INTBUFLEN (5 + SCM_LONG_BIT)
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Numbers
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
/* Note that scm_tc16_real and scm_tc16_complex are given tc16-codes that only
|
|
|
|
|
|
* differ in one bit: This way, checking if an object is an inexact number can
|
|
|
|
|
|
* be done quickly (using the TYP16S macro). */
|
|
|
|
|
|
|
2003-09-21 07:54:23 +00:00
|
|
|
|
/* Number subtype 1 to 3 (note the dependency on the predicates SCM_INEXACTP
|
|
|
|
|
|
* and SCM_NUMP) */
|
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
|
|
|
|
#define scm_tc16_big (scm_tc7_number + 1 * 256L)
|
|
|
|
|
|
#define scm_tc16_real (scm_tc7_number + 2 * 256L)
|
|
|
|
|
|
#define scm_tc16_complex (scm_tc7_number + 3 * 256L)
|
* 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
|
|
|
|
#define scm_tc16_fraction (scm_tc7_number + 4 * 256L)
|
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
|
|
|
|
|
2003-09-21 07:54:23 +00:00
|
|
|
|
#define SCM_INEXACTP(x) \
|
|
|
|
|
|
(!SCM_IMP (x) && (0xfeff & SCM_CELL_TYPE (x)) == scm_tc16_real)
|
2003-09-06 09:17:29 +00:00
|
|
|
|
#define SCM_REALP(x) (!SCM_IMP (x) && SCM_TYP16 (x) == scm_tc16_real)
|
|
|
|
|
|
#define SCM_COMPLEXP(x) (!SCM_IMP (x) && SCM_TYP16 (x) == scm_tc16_complex)
|
* __scm.h eq.c, eval.c, gc.c, hc.h, gh_data, hash.c, numbers.c,
numbers.h, objects.c, ramap.c, random.c, unif.c, unif.h: Extensive
rewrite of handling of real and complex numbers.
(SCM_FLOATS, SCM_SINGLES): These #ifdef conditionals have been
removed along with the support for floats. (Float vectors are
still supported.)
* numbers.h (SCM_BIGSIGN): Sign moved to bit 16.
(scm_makdbl): Deprecated.
(SCM_NEWREAL, SCM_NEWCOMPLEX): New macros.
(SCM_SINGP): Deprecated.
(SCM_FLO): Removed.
(SCM_INEXP, SCM_CPLXP): Deprecated.
(SCM_INEXACTP, SCM_COMPLEXP): New macros.
(SCM_COMPLEX_REAL, SCM_COMPLEX_IMAG): Renamed from
SCM_REAL, SCM_IMAG (and now only valid for complex numbers).
(SCM_REAL, SCM_IMAG): New, *deprecated*, selectors which work both
for doubles and complex numbers.
(SCM_REAL_VALUE): New selector for doubles.
(scm_double_t, scm_complex_t): New types.
(scm_dbl): Removed.
* numbers.h (struct scm_dbl): changed to represent a double cell,
with the number in the second half.
(struct scm_cplx): new, represents a complex number as a triple
cell.
2000-03-14 06:41:25 +00:00
|
|
|
|
|
2001-06-14 19:50:43 +00:00
|
|
|
|
#define SCM_REAL_VALUE(x) (((scm_t_double *) SCM2PTR (x))->real)
|
|
|
|
|
|
#define SCM_COMPLEX_MEM(x) ((scm_t_complex *) SCM_CELL_WORD_1 (x))
|
2000-09-26 21:53:49 +00:00
|
|
|
|
#define SCM_COMPLEX_REAL(x) (SCM_COMPLEX_MEM (x)->real)
|
|
|
|
|
|
#define SCM_COMPLEX_IMAG(x) (SCM_COMPLEX_MEM (x)->imag)
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2003-04-04 21:49:55 +00:00
|
|
|
|
/* Each bignum is just an mpz_t stored in a double cell starting at word 1. */
|
2004-05-06 16:42:07 +00:00
|
|
|
|
#define SCM_I_BIG_MPZ(x) (*((mpz_t *) (SCM_CELL_OBJECT_LOC((x),1))))
|
2003-04-04 21:49:55 +00:00
|
|
|
|
#define SCM_BIGP(x) (!SCM_IMP (x) && SCM_TYP16 (x) == scm_tc16_big)
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2000-03-20 14:00:27 +00:00
|
|
|
|
#define SCM_NUMBERP(x) (SCM_INUMP(x) || SCM_NUMP(x))
|
2003-04-04 21:49:55 +00:00
|
|
|
|
#define SCM_NUMP(x) (!SCM_IMP(x) \
|
* 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
|
|
|
|
&& (((0xfcff & SCM_CELL_TYPE (x)) == scm_tc7_number) \
|
|
|
|
|
|
|| ((0xfbff & SCM_CELL_TYPE (x)) == scm_tc7_number)))
|
|
|
|
|
|
/* 0xfcff (#b1100) for 0 free, 1 big, 2 real, 3 complex, then 0xfbff (#b1011) for 4 fraction */
|
|
|
|
|
|
|
|
|
|
|
|
#define SCM_FRACTIONP(x) (!SCM_IMP (x) && SCM_TYP16 (x) == scm_tc16_fraction)
|
2004-05-15 15:50:24 +00:00
|
|
|
|
#define SCM_FRACTION_NUMERATOR(x) (SCM_CELL_OBJECT_1 (x))
|
|
|
|
|
|
#define SCM_FRACTION_DENOMINATOR(x) (SCM_CELL_OBJECT_2 (x))
|
|
|
|
|
|
#define SCM_FRACTION_SET_NUMERATOR(x, v) (SCM_SET_CELL_OBJECT_1 ((x), (v)))
|
|
|
|
|
|
#define SCM_FRACTION_SET_DENOMINATOR(x, v) (SCM_SET_CELL_OBJECT_2 ((x), (v)))
|
|
|
|
|
|
|
* 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
|
|
|
|
/* I think the left half word is free in the type, so I'll use bit 17 */
|
|
|
|
|
|
#define SCM_FRACTION_REDUCED_BIT 0x10000
|
|
|
|
|
|
#define SCM_FRACTION_REDUCED_SET(x) (SCM_SET_CELL_TYPE((x), (SCM_CELL_TYPE (x) | SCM_FRACTION_REDUCED_BIT)))
|
|
|
|
|
|
#define SCM_FRACTION_REDUCED_CLEAR(x) (SCM_SET_CELL_TYPE((x), (SCM_CELL_TYPE (x) & ~SCM_FRACTION_REDUCED_BIT)))
|
|
|
|
|
|
#define SCM_FRACTION_REDUCED(x) (0x10000 & SCM_CELL_TYPE (x))
|
* __scm.h eq.c, eval.c, gc.c, hc.h, gh_data, hash.c, numbers.c,
numbers.h, objects.c, ramap.c, random.c, unif.c, unif.h: Extensive
rewrite of handling of real and complex numbers.
(SCM_FLOATS, SCM_SINGLES): These #ifdef conditionals have been
removed along with the support for floats. (Float vectors are
still supported.)
* numbers.h (SCM_BIGSIGN): Sign moved to bit 16.
(scm_makdbl): Deprecated.
(SCM_NEWREAL, SCM_NEWCOMPLEX): New macros.
(SCM_SINGP): Deprecated.
(SCM_FLO): Removed.
(SCM_INEXP, SCM_CPLXP): Deprecated.
(SCM_INEXACTP, SCM_COMPLEXP): New macros.
(SCM_COMPLEX_REAL, SCM_COMPLEX_IMAG): Renamed from
SCM_REAL, SCM_IMAG (and now only valid for complex numbers).
(SCM_REAL, SCM_IMAG): New, *deprecated*, selectors which work both
for doubles and complex numbers.
(SCM_REAL_VALUE): New selector for doubles.
(scm_double_t, scm_complex_t): New types.
(scm_dbl): Removed.
* numbers.h (struct scm_dbl): changed to represent a double cell,
with the number in the second half.
(struct scm_cplx): new, represents a complex number as a triple
cell.
2000-03-14 06:41:25 +00:00
|
|
|
|
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
2001-06-14 19:50:43 +00:00
|
|
|
|
typedef struct scm_t_double
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
|
|
|
|
|
SCM type;
|
* __scm.h eq.c, eval.c, gc.c, hc.h, gh_data, hash.c, numbers.c,
numbers.h, objects.c, ramap.c, random.c, unif.c, unif.h: Extensive
rewrite of handling of real and complex numbers.
(SCM_FLOATS, SCM_SINGLES): These #ifdef conditionals have been
removed along with the support for floats. (Float vectors are
still supported.)
* numbers.h (SCM_BIGSIGN): Sign moved to bit 16.
(scm_makdbl): Deprecated.
(SCM_NEWREAL, SCM_NEWCOMPLEX): New macros.
(SCM_SINGP): Deprecated.
(SCM_FLO): Removed.
(SCM_INEXP, SCM_CPLXP): Deprecated.
(SCM_INEXACTP, SCM_COMPLEXP): New macros.
(SCM_COMPLEX_REAL, SCM_COMPLEX_IMAG): Renamed from
SCM_REAL, SCM_IMAG (and now only valid for complex numbers).
(SCM_REAL, SCM_IMAG): New, *deprecated*, selectors which work both
for doubles and complex numbers.
(SCM_REAL_VALUE): New selector for doubles.
(scm_double_t, scm_complex_t): New types.
(scm_dbl): Removed.
* numbers.h (struct scm_dbl): changed to represent a double cell,
with the number in the second half.
(struct scm_cplx): new, represents a complex number as a triple
cell.
2000-03-14 06:41:25 +00:00
|
|
|
|
SCM pad;
|
|
|
|
|
|
double real;
|
2001-06-14 19:50:43 +00:00
|
|
|
|
} scm_t_double;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2001-06-14 19:50:43 +00:00
|
|
|
|
typedef struct scm_t_complex
|
1996-07-25 22:56:11 +00:00
|
|
|
|
{
|
* __scm.h eq.c, eval.c, gc.c, hc.h, gh_data, hash.c, numbers.c,
numbers.h, objects.c, ramap.c, random.c, unif.c, unif.h: Extensive
rewrite of handling of real and complex numbers.
(SCM_FLOATS, SCM_SINGLES): These #ifdef conditionals have been
removed along with the support for floats. (Float vectors are
still supported.)
* numbers.h (SCM_BIGSIGN): Sign moved to bit 16.
(scm_makdbl): Deprecated.
(SCM_NEWREAL, SCM_NEWCOMPLEX): New macros.
(SCM_SINGP): Deprecated.
(SCM_FLO): Removed.
(SCM_INEXP, SCM_CPLXP): Deprecated.
(SCM_INEXACTP, SCM_COMPLEXP): New macros.
(SCM_COMPLEX_REAL, SCM_COMPLEX_IMAG): Renamed from
SCM_REAL, SCM_IMAG (and now only valid for complex numbers).
(SCM_REAL, SCM_IMAG): New, *deprecated*, selectors which work both
for doubles and complex numbers.
(SCM_REAL_VALUE): New selector for doubles.
(scm_double_t, scm_complex_t): New types.
(scm_dbl): Removed.
* numbers.h (struct scm_dbl): changed to represent a double cell,
with the number in the second half.
(struct scm_cplx): new, represents a complex number as a triple
cell.
2000-03-14 06:41:25 +00:00
|
|
|
|
double real;
|
|
|
|
|
|
double imag;
|
2001-06-14 19:50:43 +00:00
|
|
|
|
} scm_t_complex;
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-11-02 00:19:12 +00:00
|
|
|
|
SCM_API SCM scm_exact_p (SCM x);
|
|
|
|
|
|
SCM_API SCM scm_odd_p (SCM n);
|
|
|
|
|
|
SCM_API SCM scm_even_p (SCM n);
|
2002-05-06 22:27:42 +00:00
|
|
|
|
SCM_API SCM scm_inf_p (SCM n);
|
|
|
|
|
|
SCM_API SCM scm_nan_p (SCM n);
|
|
|
|
|
|
SCM_API SCM scm_inf (void);
|
|
|
|
|
|
SCM_API SCM scm_nan (void);
|
2001-11-02 00:19:12 +00:00
|
|
|
|
SCM_API SCM scm_abs (SCM x);
|
|
|
|
|
|
SCM_API SCM scm_quotient (SCM x, SCM y);
|
|
|
|
|
|
SCM_API SCM scm_remainder (SCM x, SCM y);
|
|
|
|
|
|
SCM_API SCM scm_modulo (SCM x, SCM y);
|
|
|
|
|
|
SCM_API SCM scm_gcd (SCM x, SCM y);
|
|
|
|
|
|
SCM_API SCM scm_lcm (SCM n1, SCM n2);
|
|
|
|
|
|
SCM_API SCM scm_logand (SCM n1, SCM n2);
|
|
|
|
|
|
SCM_API SCM scm_logior (SCM n1, SCM n2);
|
|
|
|
|
|
SCM_API SCM scm_logxor (SCM n1, SCM n2);
|
|
|
|
|
|
SCM_API SCM scm_logtest (SCM n1, SCM n2);
|
|
|
|
|
|
SCM_API SCM scm_logbit_p (SCM n1, SCM n2);
|
|
|
|
|
|
SCM_API SCM scm_lognot (SCM n);
|
2004-03-25 21:55:20 +00:00
|
|
|
|
SCM_API SCM scm_modulo_expt (SCM n, SCM k, SCM m);
|
2001-11-02 00:19:12 +00:00
|
|
|
|
SCM_API SCM scm_integer_expt (SCM z1, SCM z2);
|
|
|
|
|
|
SCM_API SCM scm_ash (SCM n, SCM cnt);
|
|
|
|
|
|
SCM_API SCM scm_bit_extract (SCM n, SCM start, SCM end);
|
|
|
|
|
|
SCM_API SCM scm_logcount (SCM n);
|
|
|
|
|
|
SCM_API SCM scm_integer_length (SCM n);
|
* validate.h
(SCM_NUM2{SIZE,PTRDIFF,SHORT,USHORT,BITS,UBITS,INT,UINT}[_DEF]):
new macros.
* unif.h: type renaming:
scm_array -> scm_array_t
scm_array_dim -> scm_array_dim_t
the old names are deprecated, all in-Guile uses changed.
* tags.h (scm_ubits_t): new typedef, representing unsigned
scm_bits_t.
* stacks.h: type renaming:
scm_info_frame -> scm_info_frame_t
scm_stack -> scm_stack_t
the old names are deprecated, all in-Guile uses changed.
* srcprop.h: type renaming:
scm_srcprops -> scm_srcprops_t
scm_srcprops_chunk -> scm_srcprops_chunk_t
the old names are deprecated, all in-Guile uses changed.
* gsubr.c, procs.c, print.c, ports.c, read.c, rdelim.c, ramap.c,
rw.c, smob.c, sort.c, srcprop.c, stacks.c, strings.c, strop.c,
strorder.c, strports.c, struct.c, symbols.c, unif.c, values.c,
vectors.c, vports.c, weaks.c:
various int/size_t -> size_t/scm_bits_t changes.
* random.h: type renaming:
scm_rstate -> scm_rstate_t
scm_rng -> scm_rng_t
scm_i_rstate -> scm_i_rstate_t
the old names are deprecated, all in-Guile uses changed.
* procs.h: type renaming:
scm_subr_entry -> scm_subr_entry_t
the old name is deprecated, all in-Guile uses changed.
* options.h (scm_option_t.val): unsigned long -> scm_bits_t.
type renaming:
scm_option -> scm_option_t
the old name is deprecated, all in-Guile uses changed.
* objects.c: various long -> scm_bits_t changes.
(scm_i_make_class_object): flags: unsigned long -> scm_ubits_t
* numbers.h (SCM_FIXNUM_BIT): deprecated, renamed to
SCM_I_FIXNUM_BIT.
* num2integral.i.c: new file, multiply included by numbers.c, used
to "templatize" the various integral <-> num conversion routines.
* numbers.c (scm_mkbig, scm_big2num, scm_adjbig, scm_normbig,
scm_copybig, scm_2ulong2big, scm_dbl2big, scm_big2dbl):
deprecated.
(scm_i_mkbig, scm_i_big2inum, scm_i_adjbig, scm_i_normbig,
scm_i_copybig, scm_i_short2big, scm_i_ushort2big, scm_i_int2big,
scm_i_uint2big, scm_i_long2big, scm_i_ulong2big, scm_i_bits2big,
scm_i_ubits2big, scm_i_size2big, scm_i_ptrdiff2big,
scm_i_long_long2big, scm_i_ulong_long2big, scm_i_dbl2big,
scm_i_big2dbl, scm_short2num, scm_ushort2num, scm_int2num,
scm_uint2num, scm_bits2num, scm_ubits2num, scm_size2num,
scm_ptrdiff2num, scm_num2short, scm_num2ushort, scm_num2int,
scm_num2uint, scm_num2bits, scm_num2ubits, scm_num2ptrdiff,
scm_num2size): new functions.
* modules.c (scm_module_reverse_lookup): i, n: int -> scm_bits_t.x
* load.c: change int -> size_t in various places (where the
variable is used to store a string length).
(search-path): call scm_done_free, not scm_done_malloc.
* list.c (scm_ilength): return a scm_bits_t, not long.
some other {int,long} -> scm_bits_t changes.
* hashtab.c: various [u]int -> scm_bits_t changes.
scm_ihashx_closure -> scm_ihashx_closure_t (and made a typedef).
(scm_ihashx): n: uint -> scm_bits_t
use scm_bits2num instead of scm_ulong2num.
* gsubr.c: various int -> scm_bits_t changes.
* gh_data.c (gh_scm2double): no loss of precision any more.
* gh.h (gh_str2scm): len: int -> size_t
(gh_{get,set}_substr): start: int -> scm_bits_t,
len: int -> size_t
(gh_<num>2scm): n: int -> scm_bits_t
(gh_*vector_length): return scm_[u]size_t, not unsigned long.
(gh_length): return scm_bits_t, not unsigned long.
* fports.h: type renaming:
scm_fport -> scm_fport_t
the old name is deprecated, all in-Guile uses changed.
* fports.c (fport_fill_input): count: int -> scm_bits_t
(fport_flush): init_size, remaining, count: int -> scm_bits_t
* debug.h (scm_lookup_cstr, scm_lookup_soft, scm_evstr): removed
those prototypes, as the functions they prototype don't exist.
* fports.c (default_buffer_size): int -> size_t
(scm_fport_buffer_add): read_size, write_size: int -> scm_bits_t
default_size: int -> size_t
(scm_setvbuf): csize: int -> scm_bits_t
* fluids.c (n_fluids): int -> scm_bits_t
(grow_fluids): old_length, i: int -> scm_bits_t
(next_fluid_num, scm_fluid_ref, scm_fluid_set_x): n: int ->
scm_bits_t
(scm_c_with_fluids): flen, vlen: int -> scm_bits_t
* filesys.c (s_scm_open_fdes): changed calls to SCM_NUM2LONG to
the new and shiny SCM_NUM2INT.
* extensions.c: extension -> extension_t (and made a typedef).
* eval.h (SCM_IFRAME): cast to scm_bits_t, not int. just so
there are no nasty surprises if/when the various deeply magic tag
bits move somewhere else.
* eval.c: changed the locals used to store results of SCM_IFRAME,
scm_ilength and such to be of type scm_bits_t (and not int/long).
(iqq): depth, edepth: int -> scm_bits_t
(scm_eval_stack): int -> scm_bits_t
(SCM_CEVAL): various vars are not scm_bits_t instead of int.
(check_map_args, scm_map, scm_for_each): len: long -> scm_bits_t
i: int -> scm_bits_t
* environments.c: changed the many calls to scm_ulong2num to
scm_ubits2num.
(import_environment_fold): proc_as_ul: ulong -> scm_ubits_t
* dynwind.c (scm_dowinds): delta: long -> scm_bits_t
* debug.h: type renaming:
scm_debug_info -> scm_debug_info_t
scm_debug_frame -> scm_debug_frame_t
the old names are deprecated, all in-Guile uses changed.
(scm_debug_eframe_size): int -> scm_bits_t
* debug.c (scm_init_debug): use scm_c_define instead of the
deprecated scm_define.
* continuations.h: type renaming:
scm_contregs -> scm_contregs_t
the old name is deprecated, all in-Guile uses changed.
(scm_contregs_t.num_stack_items): size_t -> scm_bits_t
(scm_contregs_t.num_stack_items): ulong -> scm_ubits_t
* continuations.c (scm_make_continuation): change the type of
stack_size form long to scm_bits_t.
* ports.h: type renaming:
scm_port_rw_active -> scm_port_rw_active_t (and made a typedef)
scm_port -> scm_port_t
scm_ptob_descriptor -> scm_ptob_descriptor_t
the old names are deprecated, all in-Guile uses changed.
(scm_port_t.entry): int -> scm_bits_t.
(scm_port_t.line_number): int -> long.
(scm_port_t.putback_buf_size): int -> size_t.
* __scm.h (long_long, ulong_long): deprecated (they pollute the
global namespace and have little value besides that).
(SCM_BITS_LENGTH): new, is the bit size of scm_bits_t (i.e. of an
SCM handle).
(ifdef spaghetti): include sys/types.h and sys/stdtypes.h, if they
exist (for size_t & ptrdiff_t)
(scm_sizet): deprecated.
* Makefile.am (noinst_HEADERS): add num2integral.i.c
2001-05-24 00:50:51 +00:00
|
|
|
|
|
2001-11-02 00:19:12 +00:00
|
|
|
|
SCM_API size_t scm_iint2str (long num, int rad, char *p);
|
|
|
|
|
|
SCM_API SCM scm_number_to_string (SCM x, SCM radix);
|
|
|
|
|
|
SCM_API int scm_print_real (SCM sexp, SCM port, scm_print_state *pstate);
|
|
|
|
|
|
SCM_API int scm_print_complex (SCM sexp, SCM port, scm_print_state *pstate);
|
|
|
|
|
|
SCM_API int scm_bigprint (SCM exp, SCM port, scm_print_state *pstate);
|
|
|
|
|
|
SCM_API SCM scm_i_mem2number (const char *mem, size_t len, unsigned int radix);
|
|
|
|
|
|
SCM_API SCM scm_string_to_number (SCM str, SCM radix);
|
|
|
|
|
|
SCM_API SCM scm_make_real (double x);
|
|
|
|
|
|
SCM_API SCM scm_make_complex (double x, double y);
|
|
|
|
|
|
SCM_API SCM scm_bigequal (SCM x, SCM y);
|
|
|
|
|
|
SCM_API SCM scm_real_equalp (SCM x, SCM y);
|
|
|
|
|
|
SCM_API SCM scm_complex_equalp (SCM x, SCM y);
|
|
|
|
|
|
SCM_API SCM scm_number_p (SCM x);
|
|
|
|
|
|
SCM_API SCM scm_real_p (SCM x);
|
|
|
|
|
|
SCM_API SCM scm_integer_p (SCM x);
|
|
|
|
|
|
SCM_API SCM scm_inexact_p (SCM x);
|
|
|
|
|
|
SCM_API SCM scm_num_eq_p (SCM x, SCM y);
|
|
|
|
|
|
SCM_API SCM scm_less_p (SCM x, SCM y);
|
|
|
|
|
|
SCM_API SCM scm_gr_p (SCM x, SCM y);
|
|
|
|
|
|
SCM_API SCM scm_leq_p (SCM x, SCM y);
|
|
|
|
|
|
SCM_API SCM scm_geq_p (SCM x, SCM y);
|
|
|
|
|
|
SCM_API SCM scm_zero_p (SCM z);
|
|
|
|
|
|
SCM_API SCM scm_positive_p (SCM x);
|
|
|
|
|
|
SCM_API SCM scm_negative_p (SCM x);
|
|
|
|
|
|
SCM_API SCM scm_max (SCM x, SCM y);
|
|
|
|
|
|
SCM_API SCM scm_min (SCM x, SCM y);
|
|
|
|
|
|
SCM_API SCM scm_sum (SCM x, SCM y);
|
|
|
|
|
|
SCM_API SCM scm_difference (SCM x, SCM y);
|
|
|
|
|
|
SCM_API SCM scm_product (SCM x, SCM y);
|
|
|
|
|
|
SCM_API double scm_num2dbl (SCM a, const char * why);
|
|
|
|
|
|
SCM_API SCM scm_divide (SCM x, SCM y);
|
* 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
|
|
|
|
SCM_API SCM scm_floor (SCM x);
|
|
|
|
|
|
SCM_API SCM scm_ceiling (SCM x);
|
2001-11-02 00:19:12 +00:00
|
|
|
|
SCM_API double scm_asinh (double x);
|
|
|
|
|
|
SCM_API double scm_acosh (double x);
|
|
|
|
|
|
SCM_API double scm_atanh (double x);
|
|
|
|
|
|
SCM_API double scm_truncate (double x);
|
|
|
|
|
|
SCM_API double scm_round (double x);
|
* 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
|
|
|
|
SCM_API SCM scm_truncate_number (SCM x);
|
|
|
|
|
|
SCM_API SCM scm_round_number (SCM x);
|
2001-11-02 00:19:12 +00:00
|
|
|
|
SCM_API SCM scm_sys_expt (SCM z1, SCM z2);
|
|
|
|
|
|
SCM_API SCM scm_sys_atan2 (SCM z1, SCM z2);
|
|
|
|
|
|
SCM_API SCM scm_make_rectangular (SCM z1, SCM z2);
|
|
|
|
|
|
SCM_API SCM scm_make_polar (SCM z1, SCM z2);
|
|
|
|
|
|
SCM_API SCM scm_real_part (SCM z);
|
|
|
|
|
|
SCM_API SCM scm_imag_part (SCM z);
|
|
|
|
|
|
SCM_API SCM scm_magnitude (SCM z);
|
|
|
|
|
|
SCM_API SCM scm_angle (SCM z);
|
|
|
|
|
|
SCM_API SCM scm_exact_to_inexact (SCM z);
|
|
|
|
|
|
SCM_API SCM scm_inexact_to_exact (SCM z);
|
|
|
|
|
|
SCM_API SCM scm_trunc (SCM x);
|
|
|
|
|
|
|
|
|
|
|
|
SCM_API SCM scm_short2num (short n);
|
|
|
|
|
|
SCM_API SCM scm_ushort2num (unsigned short n);
|
|
|
|
|
|
SCM_API SCM scm_int2num (int n);
|
|
|
|
|
|
SCM_API SCM scm_uint2num (unsigned int n);
|
|
|
|
|
|
SCM_API SCM scm_long2num (long n);
|
|
|
|
|
|
SCM_API SCM scm_ulong2num (unsigned long n);
|
|
|
|
|
|
SCM_API SCM scm_size2num (size_t n);
|
2003-03-25 23:57:58 +00:00
|
|
|
|
SCM_API SCM scm_ptrdiff2num (scm_t_ptrdiff n);
|
2001-11-02 00:19:12 +00:00
|
|
|
|
SCM_API short scm_num2short (SCM num, unsigned long int pos,
|
|
|
|
|
|
const char *s_caller);
|
|
|
|
|
|
SCM_API unsigned short scm_num2ushort (SCM num, unsigned long int pos,
|
|
|
|
|
|
const char *s_caller);
|
|
|
|
|
|
SCM_API int scm_num2int (SCM num, unsigned long int pos,
|
|
|
|
|
|
const char *s_caller);
|
|
|
|
|
|
SCM_API unsigned int scm_num2uint (SCM num, unsigned long int pos,
|
|
|
|
|
|
const char *s_caller);
|
|
|
|
|
|
SCM_API long scm_num2long (SCM num, unsigned long int pos,
|
|
|
|
|
|
const char *s_caller);
|
|
|
|
|
|
SCM_API unsigned long scm_num2ulong (SCM num, unsigned long int pos,
|
|
|
|
|
|
const char *s_caller);
|
2003-03-25 23:57:58 +00:00
|
|
|
|
SCM_API scm_t_ptrdiff scm_num2ptrdiff (SCM num, unsigned long int pos,
|
|
|
|
|
|
const char *s_caller);
|
2001-11-02 00:19:12 +00:00
|
|
|
|
SCM_API size_t scm_num2size (SCM num, unsigned long int pos,
|
|
|
|
|
|
const char *s_caller);
|
2003-03-25 23:57:58 +00:00
|
|
|
|
#if SCM_SIZEOF_LONG_LONG != 0
|
2001-11-02 00:19:12 +00:00
|
|
|
|
SCM_API SCM scm_long_long2num (long long sl);
|
|
|
|
|
|
SCM_API SCM scm_ulong_long2num (unsigned long long sl);
|
|
|
|
|
|
SCM_API long long scm_num2long_long (SCM num, unsigned long int pos,
|
|
|
|
|
|
const char *s_caller);
|
|
|
|
|
|
SCM_API unsigned long long scm_num2ulong_long (SCM num, unsigned long int pos,
|
|
|
|
|
|
const char *s_caller);
|
2000-06-20 14:57:45 +00:00
|
|
|
|
#endif
|
* validate.h
(SCM_NUM2{SIZE,PTRDIFF,SHORT,USHORT,BITS,UBITS,INT,UINT}[_DEF]):
new macros.
* unif.h: type renaming:
scm_array -> scm_array_t
scm_array_dim -> scm_array_dim_t
the old names are deprecated, all in-Guile uses changed.
* tags.h (scm_ubits_t): new typedef, representing unsigned
scm_bits_t.
* stacks.h: type renaming:
scm_info_frame -> scm_info_frame_t
scm_stack -> scm_stack_t
the old names are deprecated, all in-Guile uses changed.
* srcprop.h: type renaming:
scm_srcprops -> scm_srcprops_t
scm_srcprops_chunk -> scm_srcprops_chunk_t
the old names are deprecated, all in-Guile uses changed.
* gsubr.c, procs.c, print.c, ports.c, read.c, rdelim.c, ramap.c,
rw.c, smob.c, sort.c, srcprop.c, stacks.c, strings.c, strop.c,
strorder.c, strports.c, struct.c, symbols.c, unif.c, values.c,
vectors.c, vports.c, weaks.c:
various int/size_t -> size_t/scm_bits_t changes.
* random.h: type renaming:
scm_rstate -> scm_rstate_t
scm_rng -> scm_rng_t
scm_i_rstate -> scm_i_rstate_t
the old names are deprecated, all in-Guile uses changed.
* procs.h: type renaming:
scm_subr_entry -> scm_subr_entry_t
the old name is deprecated, all in-Guile uses changed.
* options.h (scm_option_t.val): unsigned long -> scm_bits_t.
type renaming:
scm_option -> scm_option_t
the old name is deprecated, all in-Guile uses changed.
* objects.c: various long -> scm_bits_t changes.
(scm_i_make_class_object): flags: unsigned long -> scm_ubits_t
* numbers.h (SCM_FIXNUM_BIT): deprecated, renamed to
SCM_I_FIXNUM_BIT.
* num2integral.i.c: new file, multiply included by numbers.c, used
to "templatize" the various integral <-> num conversion routines.
* numbers.c (scm_mkbig, scm_big2num, scm_adjbig, scm_normbig,
scm_copybig, scm_2ulong2big, scm_dbl2big, scm_big2dbl):
deprecated.
(scm_i_mkbig, scm_i_big2inum, scm_i_adjbig, scm_i_normbig,
scm_i_copybig, scm_i_short2big, scm_i_ushort2big, scm_i_int2big,
scm_i_uint2big, scm_i_long2big, scm_i_ulong2big, scm_i_bits2big,
scm_i_ubits2big, scm_i_size2big, scm_i_ptrdiff2big,
scm_i_long_long2big, scm_i_ulong_long2big, scm_i_dbl2big,
scm_i_big2dbl, scm_short2num, scm_ushort2num, scm_int2num,
scm_uint2num, scm_bits2num, scm_ubits2num, scm_size2num,
scm_ptrdiff2num, scm_num2short, scm_num2ushort, scm_num2int,
scm_num2uint, scm_num2bits, scm_num2ubits, scm_num2ptrdiff,
scm_num2size): new functions.
* modules.c (scm_module_reverse_lookup): i, n: int -> scm_bits_t.x
* load.c: change int -> size_t in various places (where the
variable is used to store a string length).
(search-path): call scm_done_free, not scm_done_malloc.
* list.c (scm_ilength): return a scm_bits_t, not long.
some other {int,long} -> scm_bits_t changes.
* hashtab.c: various [u]int -> scm_bits_t changes.
scm_ihashx_closure -> scm_ihashx_closure_t (and made a typedef).
(scm_ihashx): n: uint -> scm_bits_t
use scm_bits2num instead of scm_ulong2num.
* gsubr.c: various int -> scm_bits_t changes.
* gh_data.c (gh_scm2double): no loss of precision any more.
* gh.h (gh_str2scm): len: int -> size_t
(gh_{get,set}_substr): start: int -> scm_bits_t,
len: int -> size_t
(gh_<num>2scm): n: int -> scm_bits_t
(gh_*vector_length): return scm_[u]size_t, not unsigned long.
(gh_length): return scm_bits_t, not unsigned long.
* fports.h: type renaming:
scm_fport -> scm_fport_t
the old name is deprecated, all in-Guile uses changed.
* fports.c (fport_fill_input): count: int -> scm_bits_t
(fport_flush): init_size, remaining, count: int -> scm_bits_t
* debug.h (scm_lookup_cstr, scm_lookup_soft, scm_evstr): removed
those prototypes, as the functions they prototype don't exist.
* fports.c (default_buffer_size): int -> size_t
(scm_fport_buffer_add): read_size, write_size: int -> scm_bits_t
default_size: int -> size_t
(scm_setvbuf): csize: int -> scm_bits_t
* fluids.c (n_fluids): int -> scm_bits_t
(grow_fluids): old_length, i: int -> scm_bits_t
(next_fluid_num, scm_fluid_ref, scm_fluid_set_x): n: int ->
scm_bits_t
(scm_c_with_fluids): flen, vlen: int -> scm_bits_t
* filesys.c (s_scm_open_fdes): changed calls to SCM_NUM2LONG to
the new and shiny SCM_NUM2INT.
* extensions.c: extension -> extension_t (and made a typedef).
* eval.h (SCM_IFRAME): cast to scm_bits_t, not int. just so
there are no nasty surprises if/when the various deeply magic tag
bits move somewhere else.
* eval.c: changed the locals used to store results of SCM_IFRAME,
scm_ilength and such to be of type scm_bits_t (and not int/long).
(iqq): depth, edepth: int -> scm_bits_t
(scm_eval_stack): int -> scm_bits_t
(SCM_CEVAL): various vars are not scm_bits_t instead of int.
(check_map_args, scm_map, scm_for_each): len: long -> scm_bits_t
i: int -> scm_bits_t
* environments.c: changed the many calls to scm_ulong2num to
scm_ubits2num.
(import_environment_fold): proc_as_ul: ulong -> scm_ubits_t
* dynwind.c (scm_dowinds): delta: long -> scm_bits_t
* debug.h: type renaming:
scm_debug_info -> scm_debug_info_t
scm_debug_frame -> scm_debug_frame_t
the old names are deprecated, all in-Guile uses changed.
(scm_debug_eframe_size): int -> scm_bits_t
* debug.c (scm_init_debug): use scm_c_define instead of the
deprecated scm_define.
* continuations.h: type renaming:
scm_contregs -> scm_contregs_t
the old name is deprecated, all in-Guile uses changed.
(scm_contregs_t.num_stack_items): size_t -> scm_bits_t
(scm_contregs_t.num_stack_items): ulong -> scm_ubits_t
* continuations.c (scm_make_continuation): change the type of
stack_size form long to scm_bits_t.
* ports.h: type renaming:
scm_port_rw_active -> scm_port_rw_active_t (and made a typedef)
scm_port -> scm_port_t
scm_ptob_descriptor -> scm_ptob_descriptor_t
the old names are deprecated, all in-Guile uses changed.
(scm_port_t.entry): int -> scm_bits_t.
(scm_port_t.line_number): int -> long.
(scm_port_t.putback_buf_size): int -> size_t.
* __scm.h (long_long, ulong_long): deprecated (they pollute the
global namespace and have little value besides that).
(SCM_BITS_LENGTH): new, is the bit size of scm_bits_t (i.e. of an
SCM handle).
(ifdef spaghetti): include sys/types.h and sys/stdtypes.h, if they
exist (for size_t & ptrdiff_t)
(scm_sizet): deprecated.
* Makefile.am (noinst_HEADERS): add num2integral.i.c
2001-05-24 00:50:51 +00:00
|
|
|
|
|
2001-11-02 00:19:12 +00:00
|
|
|
|
SCM_API SCM scm_float2num (float n);
|
|
|
|
|
|
SCM_API SCM scm_double2num (double n);
|
|
|
|
|
|
SCM_API float scm_num2float (SCM num, unsigned long int pos,
|
|
|
|
|
|
const char *s_caller);
|
|
|
|
|
|
SCM_API double scm_num2double (SCM num, unsigned long int pos,
|
|
|
|
|
|
const char *s_caller);
|
2001-09-23 21:25:26 +00:00
|
|
|
|
|
2003-04-04 21:49:55 +00:00
|
|
|
|
|
|
|
|
|
|
/* bignum internal functions */
|
|
|
|
|
|
SCM_API SCM scm_i_mkbig (void);
|
|
|
|
|
|
SCM_API SCM scm_i_normbig (SCM x);
|
|
|
|
|
|
SCM_API int scm_i_bigcmp (SCM a, SCM b);
|
|
|
|
|
|
SCM_API SCM scm_i_dbl2big (double d);
|
* 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
|
|
|
|
SCM_API SCM scm_i_dbl2num (double d);
|
2003-04-04 21:49:55 +00:00
|
|
|
|
SCM_API double scm_i_big2dbl (SCM b);
|
|
|
|
|
|
SCM_API SCM scm_i_short2big (short n);
|
|
|
|
|
|
SCM_API SCM scm_i_ushort2big (unsigned short n);
|
|
|
|
|
|
SCM_API SCM scm_i_int2big (int n);
|
|
|
|
|
|
SCM_API SCM scm_i_uint2big (unsigned int n);
|
|
|
|
|
|
SCM_API SCM scm_i_long2big (long n);
|
|
|
|
|
|
SCM_API SCM scm_i_ulong2big (unsigned long n);
|
|
|
|
|
|
SCM_API SCM scm_i_size2big (size_t n);
|
|
|
|
|
|
SCM_API SCM scm_i_ptrdiff2big (scm_t_ptrdiff n);
|
|
|
|
|
|
|
|
|
|
|
|
#if SCM_SIZEOF_LONG_LONG != 0
|
|
|
|
|
|
SCM_API SCM scm_i_long_long2big (long long n);
|
|
|
|
|
|
SCM_API SCM scm_i_ulong_long2big (unsigned long long n);
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
* 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
|
|
|
|
/* ratio functions */
|
|
|
|
|
|
SCM_API SCM scm_make_ratio (SCM num, SCM den);
|
|
|
|
|
|
SCM_API SCM scm_rationalize (SCM x, SCM err);
|
|
|
|
|
|
SCM_API SCM scm_numerator (SCM z);
|
|
|
|
|
|
SCM_API SCM scm_denominator (SCM z);
|
|
|
|
|
|
SCM_API SCM scm_rational_p (SCM z);
|
|
|
|
|
|
|
|
|
|
|
|
/* fraction internal functions */
|
|
|
|
|
|
SCM_API double scm_i_fraction2double (SCM z);
|
|
|
|
|
|
SCM_API SCM scm_i_fraction_equalp (SCM x, SCM y);
|
|
|
|
|
|
SCM_API int scm_i_print_fraction (SCM sexp, SCM port, scm_print_state *pstate);
|
|
|
|
|
|
|
2003-04-04 21:49:55 +00:00
|
|
|
|
|
2001-11-07 15:08:45 +00:00
|
|
|
|
#ifdef GUILE_DEBUG
|
|
|
|
|
|
SCM_API SCM scm_sys_check_number_conversions (void);
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2001-11-02 00:19:12 +00:00
|
|
|
|
SCM_API void scm_init_numbers (void);
|
1996-07-25 22:56:11 +00:00
|
|
|
|
|
2001-07-30 19:35:15 +00:00
|
|
|
|
#endif /* SCM_NUMBERS_H */
|
2000-03-19 19:01:16 +00:00
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
Local Variables:
|
|
|
|
|
|
c-file-style: "gnu"
|
|
|
|
|
|
End:
|
|
|
|
|
|
*/
|