Skip to content

Commit

Permalink
#740 Simplify unsigned binary to long conversion when values can't be…
Browse files Browse the repository at this point in the history
… negative.
  • Loading branch information
yruslan committed Jan 23, 2025
1 parent 888d212 commit e0288ba
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ object BinaryNumberDecoders {
if (bytes.length < 4) {
return null
}
val v: Long = ((bytes(0) & 255L) << 24L) | ((bytes(1) & 255L) << 16L) | ((bytes(2) & 255L) << 8L) | (bytes(3) & 255L)
if (v<0) null else v
((bytes(0) & 255L) << 24L) | ((bytes(1) & 255L) << 16L) | ((bytes(2) & 255L) << 8L) | (bytes(3) & 255L)
}

def decodeBinaryUnsignedIntLittleEndian(bytes: Array[Byte]): Integer = {
Expand All @@ -102,8 +101,7 @@ object BinaryNumberDecoders {
if (bytes.length < 4) {
return null
}
val v: Long = ((bytes(3) & 255L) << 24L) | ((bytes(2) & 255L) << 16L) | ((bytes(1) & 255L) << 8L) | (bytes(0) & 255L)
if (v<0) null else v
((bytes(3) & 255L) << 24L) | ((bytes(2) & 255L) << 16L) | ((bytes(1) & 255L) << 8L) | (bytes(0) & 255L)
}

def decodeBinarySignedLongBigEndian(bytes: Array[Byte]): java.lang.Long = {
Expand Down

0 comments on commit e0288ba

Please sign in to comment.