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

FieldInstruction::encodeSignedInteger with negative numbers #122

Open
GoogleCodeExporter opened this issue Apr 21, 2015 · 0 comments
Open

Comments

@GoogleCodeExporter
Copy link

This method is missing a case in the negative numbers branch:  
0x0080000000000000LL < absv <= 0x4000000000000000LL. And the last else we will 
need to add a byte with value 7F at the beginning.

    else if (absv <= 0x4000000000000000LL)
    {
      destination.putByte(((value >> 56)  & 0x7F)); // 7F.. .... .... ....
      destination.putByte(((value >> 49)  & 0x7F)); // ..FE .... .... ....
      destination.putByte(((value >> 42)  & 0x7F)); // ...1 FC.. .... ....
      destination.putByte(((value >> 35)  & 0x7F)); // .... .3F8 .... ....
      destination.putByte(((value >> 28)  & 0x7F)); // .... ...7 F... ....
      destination.putByte(((value >> 21)  & 0x7F)); // .... .... .FE. ....
      destination.putByte(((value >> 14)  & 0x7F)); // .... .... ...1 FC..
      destination.putByte(((value >> 7)   & 0x7F)); // .... .... .... 3F8.
      destination.putByte((value & 0x7F)  | 0x80);  // .... .... .... ..7f
    }
    else
    {
      destination.putByte(((value >> 63)  & 0x7F)); // 8... .... .... ....  (this will always be 7F)
      destination.putByte(((value >> 56)  & 0x7F)); // 7F.. .... .... ....
      destination.putByte(((value >> 49)  & 0x7F)); // ..FE .... .... ....
      destination.putByte(((value >> 42)  & 0x7F)); // ...1 FC.. .... ....
      destination.putByte(((value >> 35)  & 0x7F)); // .... .3F8 .... ....
      destination.putByte(((value >> 28)  & 0x7F)); // .... ...7 F... ....
      destination.putByte(((value >> 21)  & 0x7F)); // .... .... .FE. ....
      destination.putByte(((value >> 14)  & 0x7F)); // .... .... ...1 FC..
      destination.putByte(((value >> 7)   & 0x7F)); // .... .... .... 3F8.
      destination.putByte((value & 0x7F)  | 0x80);  // .... .... .... ..7f
    }
  }


FILE: src/Codecs/FieldInstruction.cpp

Original issue reported on code.google.com by [email protected] on 24 Sep 2013 at 2:42

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

No branches or pull requests

1 participant