unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Mark H Weaver <mhw@netris.org>
To: guile-devel@gnu.org
Subject: Re: Immediate doubles (up to 2^256) and rationals coming to Guile 3
Date: Thu, 06 Jun 2019 08:56:59 -0400	[thread overview]
Message-ID: <87v9xic1mx.fsf@netris.org> (raw)
In-Reply-To: <87zhmvaw5p.fsf@netris.org> (Mark H. Weaver's message of "Thu, 06 Jun 2019 05:40:39 -0400")

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



  reply	other threads:[~2019-06-06 12:56 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-06  9:40 Immediate doubles (up to 2^256) and rationals coming to Guile 3 Mark H Weaver
2019-06-06 12:56 ` Mark H Weaver [this message]
2019-06-06 19:37 ` Arne Babenhauserheide
2019-06-12  0:03   ` Mark H Weaver
2019-06-06 20:09 ` tomas
2019-06-07 19:46 ` Ludovic Courtès
2019-06-09 16:56   ` Mark H Weaver
2019-06-09 17:30     ` Mark H Weaver
2019-06-11  8:39     ` Ludovic Courtès
2019-06-11 10:58       ` Mark H Weaver
2019-06-11 12:21         ` Ludovic Courtès
2019-06-11 11:34       ` Mark H Weaver
2019-06-08  1:13 ` Mark H Weaver
2019-06-08  8:07   ` Arne Babenhauserheide
2019-06-08  9:08     ` Chris Vine
2019-06-08  9:46       ` Arne Babenhauserheide
2019-06-08 10:24         ` Chris Vine
2019-06-08 13:12       ` Hans Åberg

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=87v9xic1mx.fsf@netris.org \
    --to=mhw@netris.org \
    --cc=guile-devel@gnu.org \
    /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).