decodeAsInt32 function

int decodeAsInt32(
  1. int rawVarint
)

Interprets rawVarint as a signed 32-bit integer.

Truncates to the lowest 32 bits and sign-extends by shifting left then arithmetic-shifting right.

Implementation

int decodeAsInt32(int rawVarint) {
  // Mask to 32 bits, then sign-extend: shift left by 32 to place bit 31
  // into the sign position of a 64-bit int, then arithmetic right shift back.
  return (rawVarint << 32) >> 32;
}