fixnum icon indicating copy to clipboard operation
fixnum copied to clipboard

support unsigned 64 bit integers

Open skybrian opened this issue 10 years ago • 3 comments

The protobuf library stores unsigned 64-bit integers in an Int64 instance. This preserves the value, but it's confusing because methods like isNegative() return the wrong thing. It would be nice to have a separate class to handle unsigned 64-bit integers.

skybrian avatar Aug 11 '15 20:08 skybrian

If we had big int values in dart2js like we do in the VM, we would not have an Int64 class and just use big ints and occasionally coerce the value in range, via x.toSigned(64) or x.toUnsigned(64).

Maybe the Int64 class should handle both signed and unsigned values.

There could be an unsigned bit that can be set via a named optional argument in parsing or via conversion of a (signed) Int64, e.g. x.toUnsigned(64). The bit would be sticky in operations (signed + unsigned -> unsigned)

Provided the behaviour without the unsigned bit is unchanged, this could be a non-breaking change.

Other than the sticky bit, many operations would remain the same. Shifting and division operators would require some tweaks. The complicated and expensive operations (parsing, formatting, division) already internally use unsigned intermediate arithmetic surrounded by sign fixups.

rakudrama avatar Oct 16 '15 20:10 rakudrama

Any chance this feature request could get some love?

tav avatar Apr 04 '18 17:04 tav

@tav How are you using Int64? Depending on what you are doing, you might be able to use BigInt from corelib.

rakudrama avatar Apr 09 '18 22:04 rakudrama