PSON
PSON copied to clipboard
Solve #9
Fix #9
Doesn't that just move the issue from encoding to evaluation of the value? val | 0
yields a 32-bit signed integer value (have you considered using longs?).
No, purpose of this code is to check whether val |0 equals val(which means whether val is a 32bit integer). I don't know whether ByteBuffer can solve Long, but your next line code is 'zigZagEncode32'. obviously it should only receive a 32bit integer.
Besides, when we are using a long int, zigzag encoding will not reduce the final size as much as encoding a small int. I think it's ok to treat the value as a number(double).
ByteBuffer treat Long values as a special object, encode from a number but decode to a object is bad, I think it's better to keep using number. Treat big number as float will solve my problem. To who do not want precision loss, they can explicit convert value into Long object.
No, I thought wrong. There's no precision loss because number is a double.