From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.devel Subject: Re: Immediate doubles (up to 2^256) and rationals coming to Guile 3 Date: Thu, 06 Jun 2019 08:56:59 -0400 Message-ID: <87v9xic1mx.fsf@netris.org> References: <87zhmvaw5p.fsf@netris.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="120671"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Jun 06 14:59:51 2019 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hYrzi-000VA7-U1 for guile-devel@m.gmane.org; Thu, 06 Jun 2019 14:59:51 +0200 Original-Received: from localhost ([127.0.0.1]:60150 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYrzb-00009M-E0 for guile-devel@m.gmane.org; Thu, 06 Jun 2019 08:59:43 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:60865) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYrz8-00007E-Tt for guile-devel@gnu.org; Thu, 06 Jun 2019 08:59:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hYrz7-00052I-0s for guile-devel@gnu.org; Thu, 06 Jun 2019 08:59:14 -0400 Original-Received: from world.peace.net ([64.112.178.59]:60526) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hYrz6-0004t7-Th for guile-devel@gnu.org; Thu, 06 Jun 2019 08:59:12 -0400 Original-Received: from mhw by world.peace.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hYrz5-00079f-EF; Thu, 06 Jun 2019 08:59:11 -0400 In-Reply-To: <87zhmvaw5p.fsf@netris.org> (Mark H. Weaver's message of "Thu, 06 Jun 2019 05:40:39 -0400") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 64.112.178.59 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.21 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 Original-Sender: "guile-devel" Xref: news.gmane.org gmane.lisp.guile.devel:19944 Archived-At: Earlier I wrote: > There's also a nice way to extract the denominator from a fixrat: mask > out the sign bit, shift right 5 bits, and interpret it as an IEEE > double. The denominator will be the integer part of the resulting > value, with the numerator in the fraction bits. Simply cast this double > to an integer to discard the numerator bits. Sorry, I forgot a step in the description above. You must also set the most significant bit of the biased exponent field after shifting right. > Here are the tags used in my draft implementation: > > ;; /* with iflos: xxx: iflo (000 < xxx < 110) > ;; (64-bit) 1111: fixnum > ;; 0111: fixrat > ;; > ;; 000: heap object > ;; tttt0110: immediate non-number > ;; 1110: [NOT_SCM] > ;; 11110: [NOT_SCM] struct tag > ;; ttttt101110: [NOT_SCM] non-pair non-struct non-smob tag > ;; ttttttttx1001110: [NOT_SCM] smob I should also mention that although the current patch set adds about 4 bits to the size of all heap tags, e.g. changing most tc7 tags to tc11, I can see a way to avoid this: we could tag pairs in the low bits of their pointers, instead of in their CARs. More concretely, 1110 would become the "pair pointer" tag, thus eliminating the need for the 1110 "NOT_SCM" tag (a.k.a. the non-pair heap object tag). This would eliminate the need to change the heap tags at all, and dramatically reduce the size of my patch set. Moreover, the low bit would no longer need to be 1, so we would have many more tc7 tags to work with. Mark