[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Immediate doubles (up to 2^256) and rationals coming to Guile 3

From: Mark H Weaver
Subject: Re: Immediate doubles (up to 2^256) and rationals coming to Guile 3
Date: Thu, 06 Jun 2019 08:56:59 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux)

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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]