Is there a way to force the encoder to only use bigint, and always use most compact representation?
The only number I'm handling are ints, and typically using bigint since they may be large.
I want the encoding in JS to be the same as say an implementation in rust, in which int are encoded in the most compact form.
When I try to encode 1n I get
encoder.encode(1n).toString("hex")
// '1b0000000000000001'
But i want it to say 1. I get this helpful for round tripping.
In this case I can convert to Number
encoder.encode(Number(1n)).toString("hex")
//'01'
This is what I want.
However the same does not work for
encoder.encode(Number(-4294967296n)).toString("hex")
//'fbc1f0000000000000'
whereas I would like it to 3AFFFFFFFF
The only number I'm handling are ints, and typically using bigint since they may be large.
I want the encoding in JS to be the same as say an implementation in rust, in which int are encoded in the most compact form.
When I try to encode
1nI getBut i want it to say 1. I get this helpful for round tripping.
In this case I can convert to
NumberThis is what I want.
However the same does not work for
whereas I would like it to
3AFFFFFFFF