PSON icon indicating copy to clipboard operation
PSON copied to clipboard

Solve #9

Open tdzl2003 opened this issue 7 years ago • 4 comments

Fix #9

tdzl2003 avatar Sep 20 '17 14:09 tdzl2003

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?).

dcodeIO avatar Sep 20 '17 22:09 dcodeIO

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).

tdzl2003 avatar Sep 22 '17 16:09 tdzl2003

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.

tdzl2003 avatar Sep 22 '17 16:09 tdzl2003

No, I thought wrong. There's no precision loss because number is a double.

tdzl2003 avatar Sep 27 '17 08:09 tdzl2003