Skip to content

FieldInstruction::encodeSignedInteger with negative numbers #122

@GoogleCodeExporter

Description

@GoogleCodeExporter
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 fernand...@gmail.com on 24 Sep 2013 at 2:42

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions