On Sat, Feb 10, 2024 at 07:58 Chris Muller <asqueaker@gmail.com> wrote:
On Fri, Feb 9, 2024 at 11:55 PM Vanessa Freudenberg <vanessa@codefrau.net> wrote:
On Fri, Feb 9, 2024 at 9:41 PM Chris Muller <asqueaker@gmail.com> wrote:
I feel that Christoph's request kinda shows us that there is a desire for a universal, friendly, #asByteArray and #fromByteArray: pair(s) that "just work" together for the cases when only compatibility matters, and not the particular byte order, and is therefore worthy of consideration.

Wouldn't that imply that #asByteArray and #fromByteArray: would have to be the inverse of each other? Currently that's not possible because, as stated before, at least for large integers #asByteArray currently answers the same array for different numbers.

ByteArray's only support element values between 0 and 255.  Attempting to convert -1 to a ByteArray rightly produces an error, as I thought you mentioned before.

I suggested it should raise an error, which would make the behavior better defined. Right now e. g. -1e100 and 1e100 produce the same byte array. 

I guess we could start deprecating it for negative integers, then again, I don’t really know the use case. 

Vanessa