From bdf26b606bb5e5b993f2a8f7e83492cfc2ee62d8 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Tue, 18 Nov 2003 20:01:57 +0000 Subject: [PATCH] *** empty log message *** --- NEWS | 42 +++++++++++++++++++++++++++++++++++++++++ THANKS | 1 + libguile/ChangeLog | 45 ++++++++++++++++++++++++++++++++++++++++++++ test-suite/ChangeLog | 11 +++++++++++ 4 files changed, 99 insertions(+) diff --git a/NEWS b/NEWS index e802eecd3..4c697aac1 100644 --- a/NEWS +++ b/NEWS @@ -452,6 +452,48 @@ platform supports this, too. The two zeros are equal according to (eqv? 0.0 (- 0.0)) => #f +** Guile now has exact rationals. + +Guile can now represent fractions such as 1/3 exactly. Computing with +them is also done exactly, of course: + + (* 1/3 3/2) + => 1/2 + +** 'floor', 'ceiling', 'round' and 'truncate' now return exact numbers + for exact arguments. + +For example: (floor 2) now returns an exact 2 where in the past it +returned an inexact 2.0. Likewise, (floor 5/4) returns an exact 1. + +** inexact->exact no longer returns only integers. + +Without exact rationals, the closest exact number was always an +integer, but now inexact->exact returns the fraction that is exactly +equal to a floating point number. For example: + + (inexact->exact 1.234) + => 694680242521899/562949953421312 + +When you want the old behavior, use 'round' explicitely: + + (inexact->exact (round 1.234)) + => 1 + +** New function 'rationalize'. + +This function finds a simple fraction that is close to a given real +number. For example (and compare with inexact->exact above): + + (rationalize 1.234 0.0005) + => 58/47 + +** 'odd?' and 'even?' work also for inexact integers. + +Previously, (odd? 1.0) would signal an error since only exact integers +were recognized as integers. Now (odd? 1.0) returns #t, (odd? 2.0) +returns #f and (odd? 1.5) signals an error. + ** We now have uninterned symbols. The new function 'make-symbol' will return a uninterned symbol. This diff --git a/THANKS b/THANKS index 336b1aa62..babdf2fd2 100644 --- a/THANKS +++ b/THANKS @@ -6,6 +6,7 @@ Contributors since the last release: Thien-Thi Nguyen Han-Wen Nienhuys Kevin Ryde + Bill Schottstaedt Sponsors since the last release: diff --git a/libguile/ChangeLog b/libguile/ChangeLog index d69f16495..970c227e2 100644 --- a/libguile/ChangeLog +++ b/libguile/ChangeLog @@ -1,3 +1,48 @@ +2003-11-18 Marius Vollmer + + Support for exact fractions from Bill Schottstaedt! Thanks! + + * 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 "" 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 Rob Browning * gen-scmconfig.c (main): remove public definition of diff --git a/test-suite/ChangeLog b/test-suite/ChangeLog index b5de860d2..f80abc29f 100644 --- a/test-suite/ChangeLog +++ b/test-suite/ChangeLog @@ -1,3 +1,14 @@ +2003-11-18 Marius Vollmer + + * tests/numbers.test ("string->number"): Expect exact rationals + for things like "1/2" and "#e1.2". + ("inexact->exact"): Expect overflow error for infs and nans. + + * tests/fractions.test: New file from Bill Schottstaedt. Thanks! + + * tests/bit-operations.test (fixnum-bit): Round the result so that + fixnum-bit really is an integer. + 2003-11-17 Marius Vollmer * tests/srfi-17.test: Expect a "Bad variable" error for (set! #f