Skip to content

Commit

Permalink
Merge pull request #1662 from DSheirer/1661-dmr-gps-location-parsing-…
Browse files Browse the repository at this point in the history
…error

#1661 DMR Talker GPS Lat/Long Values Incorrect
  • Loading branch information
DSheirer authored Oct 5, 2023
2 parents c96349f + 2f2998d commit 4912abb
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/main/java/io/github/dsheirer/bits/BinaryMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -844,13 +844,18 @@ public int getInt(int start, int end)
*/
public int getTwosComplement(int start, int end)
{
BinaryMessage sub = getSubMessage(start, end);
boolean negative = sub.get(start);
sub.flip(0, sub.size());

int value = sub.getInt(0, sub.size()) + 1;
value *= (negative ? -1 : 1);
return value;
if(get(start))
{
//Negative value - flip and add one
BinaryMessage fragment = getSubMessage(start, end);
fragment.flip(0, fragment.size());
return fragment.getInt(1, fragment.size()) + 1;
}
else
{
//Positive value - return the contents.
return getInt(start + 1, end);
}
}


Expand Down

0 comments on commit 4912abb

Please sign in to comment.