Sigh. Just an update in case Scott happens to look at this today.
The difficulty is that the conversion to long function (lng.fromInt$)
uses bitwise operations to parse the number into the new bigint
format, but Javascript represents numbers internally in 64 bit
floating point form, while the bitwise operations only work on a 32-
bit integer version of a number. To do this Javascript basically
truncates the fractional portion of any number, returns the integer
portion as a 32 bit number (losing precision), and then this is what
lng.fromInt$ converts.
To solve the problem I will probably do something kludgey like convert
the number to binary using toString(2), detect the decimal point, and
if one is found, work on the string rather than doing actual bit ops.
This will be as slow as whatever.
Alternately, at least for my purposes, lng could just be altered to
use the internal 64-bit representation. I'm not sure what this will
mean in terms of compatibility with other Python implementations and
expected expression results, but for my purposes it's better (gives a
faster and guaranteed to be bug-free result). I'd just modify lng to
do nothing more than return the simplest Javascript version of an
operation.
I'd like some input back from Scott as to why lng was added instead of
just letting Javascript do numbers its way, so I can decide how to
approach this. And if I've finished by the time he sees this, so be
it.