On Saturday, August 24, 2013 2:24:07 PM UTC-5, luser- -droog wrote:
>
> Hurray!
>
>
> ^test itp.c
> loading init.ps...
> loading err.ps...
> $error
> Xpost3 version 0.0
> PS>1 /this def
> PS>1.0 load
> PS<1>=
> this
> PS><operator 1 exch 0x407b85>bye!
The way I finally implemented it was a little different than the
way I described while planning it.
The extended number type is essentially an IEEE 754 double,
with the bottom 20 bits discarded. The 11-bit sign and exponent
portion is stored in the spare 16-bit word in the object, and
the 53 bit fraction truncated and stored in the 32-bit payload word.
Integers and reals are converted to this type when performing
dictionary lookup (at the same point where strings are converted
to names), and then converted back to the original number type
when enumerated by `forall`.
The conversion back to the original type is simply the reverse of
the above. 11-bite from the spare word shifted to the top of
a 64-bit value, 32-bits from the payload word ORed-in, and the
bottom 20-bits left zero. Then the 64-bit value is treated as
an IEEE 754 double and coerced to int or float according to
the flag set when the extended object was created.
There are still 5 unused bits in the spare word. It might be
simpler (with increased accuracy) to ignore the internal structure
of the double and just take the top 48 bits....