From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Marius Vollmer Newsgroups: gmane.lisp.guile.devel Subject: Re: ratio implementation Date: Tue, 07 Oct 2003 17:24:16 +0200 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: <87u16lcbq7.fsf@zagadka.ping.de> References: <3F250809.9030108@ccrma.stanford.edu> <87smmyibk7.fsf@zagadka.ping.de> <3F6637EC.7010004@dirk-herrmanns-seiten.de> <3F66F68B.3070100@ccrma.stanford.edu> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1065540416 14206 80.91.224.253 (7 Oct 2003 15:26:56 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 7 Oct 2003 15:26:56 +0000 (UTC) Cc: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Oct 07 17:26:54 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1A6tji-0007l4-01 for ; Tue, 07 Oct 2003 17:26:54 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1A6tiJ-0000ti-Jx for guile-devel@m.gmane.org; Tue, 07 Oct 2003 11:25:27 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1A6ths-0000aS-0S for guile-devel@gnu.org; Tue, 07 Oct 2003 11:25:00 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1A6thD-0008O7-10 for guile-devel@gnu.org; Tue, 07 Oct 2003 11:24:50 -0400 Original-Received: from [129.217.163.1] (helo=mail.dt.e-technik.uni-dortmund.de) by monty-python.gnu.org with esmtp (Exim 4.24) id 1A6thC-0008O4-2J for guile-devel@gnu.org; Tue, 07 Oct 2003 11:24:18 -0400 Original-Received: from zagadka.ping.de (unknown [192.168.2.2]) by mail.dt.e-technik.uni-dortmund.de (Postfix) with SMTP id 0042710C6B for ; Tue, 7 Oct 2003 17:24:17 +0200 (CEST) Original-Received: (qmail 30800 invoked by uid 1000); 7 Oct 2003 15:24:16 -0000 Original-To: Bill Schottstaedt In-Reply-To: <3F66F68B.3070100@ccrma.stanford.edu> (Bill Schottstaedt's message of "Tue, 16 Sep 2003 04:39:55 -0700") User-Agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Developers list for Guile, the GNU extensibility library List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.devel:2848 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:2848 Bill Schottstaedt writes: > > That is, instead of using "long", I'd say we simply use "SCM" and > > instead of "+", "==", etc, we use use "scm_sum", "scm_num_eq_p", etc. > > Also, instead of mallocing scm_t_ratio, we can use double cells, which > > should be more efficient. > > > > Any takers? > > Looks straightforward, but I may not get around to it right away. > Should I wait for Dirk's type-related changes? No, I don't think that is needed. Dirk, what do you think? > Also, I haven't looked closely at double cells, though I assume > (from a glance at the scm_t_double stuff) that I can include my > "reduce" flag as well as the numerator and denominator. Yes, double cells are just like ordinary cells, they only have four slots instead of two. One (half) slot is taken for type information, leaving three for the fraction stuff. There are unused bits in the first slot, and you could put your 'reduce' flag there as well. > > (Also I didn't really check whether your rationals behave like R5RS > > demands it. Did you? We should be sure to follow R5RS.) > > Yes, I think it follows R5RS. See test-ratios.scm for some tests. > I could make these fit into 'make check'. That would be good. > > A ratio is exact, while a real is not. Thus, I'd say that ratio? is > > not really necessary. There should be no reason to add anything eyond > > R5RS for ratios. > > Ok -- "exact?" used to return #f for 3/4 -- hence the confusion. Yes, but only because we didn't have exact rationals, right? > >> An alternative would be to make "rational?" rational. > > That would violate R5RS, wouldn't it? > > I don't think so. You are allowed to make rational? be the same > as real?, but you can also distinguish them. My druthers would > be for rational? to return #t for a ratio, #f for a float. > Why have it at all if it is just a synonym for "real?"? Hmmm, I see. My take would be that our floats are always inexact rationals. An example for a real that wouldn't also be a rational would be an exact representation of pi, I'd say. But I also agree that this way lays madness and that you'd probably need a full blown symbolic algebra system for this to actually be useful. -- 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