From: Marius Vollmer <mvo@zagadka.de>
Subject: HEAD has now exact fractions
Date: Tue, 18 Nov 2003 23:14:21 +0100 [thread overview]
Message-ID: <877k1xnx36.fsf@zagadka.ping.de> (raw)
Hi,
I have committed the exact fraction support from Bill Schottstaedt.
Thanks alot Bill!
Please give it a beating and report all things you notice.
I have changed Bill's original code to varying degrees, so don't blame
him for anything that looks wrong.
Here are the relevant NEWS entries:
** 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.
--
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3 331E FAF8 226A D5D4 E405
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
next reply other threads:[~2003-11-18 22:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-18 22:14 Marius Vollmer [this message]
2003-11-18 22:23 ` HEAD has now exact fractions Neil Jerram
2003-11-18 22:54 ` Kevin Ryde
2003-11-19 0:05 ` Marius Vollmer
2003-11-19 0:59 ` Kevin Ryde
2003-11-19 2:03 ` Neil Jerram
2003-11-19 4:33 ` Marius Vollmer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877k1xnx36.fsf@zagadka.ping.de \
--to=mvo@zagadka.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).