Skip to content

Commit

Permalink
Merge pull request #4 from jjtara/master
Browse files Browse the repository at this point in the history
Fixing bug for integer -1
  • Loading branch information
naphaso committed Aug 25, 2015
2 parents e54e9fe + f0feaec commit 367fb90
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void decoder::run() {
break;
case 1: // negative integer
if(minorType < 24) {
_listener->on_integer(-minorType);
_listener->on_integer(-1 -minorType);
} else if(minorType == 24) { // 1 byte
_currentLength = 1;
_state = STATE_NINT;
Expand Down
4 changes: 2 additions & 2 deletions src/encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ void encoder::write_int(unsigned long long value) {

void encoder::write_int(long long value) {
if(value < 0) {
write_type_value(1, (unsigned long long) -value);
write_type_value(1, (unsigned long long) -(value+1));
} else {
write_type_value(0, (unsigned long long) value);
}
}

void encoder::write_int(int value) {
if(value < 0) {
write_type_value(1, (unsigned int) -value);
write_type_value(1, (unsigned int) -(value+1));
} else {
write_type_value(0, (unsigned int) value);
}
Expand Down

0 comments on commit 367fb90

Please sign in to comment.