Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solve #9 #10

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Solve #9 #10

wants to merge 3 commits into from

Conversation

tdzl2003
Copy link

@tdzl2003 tdzl2003 commented Sep 20, 2017

Fix #9

@dcodeIO
Copy link
Owner

dcodeIO commented Sep 20, 2017

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

@tdzl2003
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants