Skip to content

Instantly share code, notes, and snippets.

@evdokimovm
Created May 29, 2020 15:29
Show Gist options
  • Save evdokimovm/62d8e2ee86ea0e467eda8cbb708becf6 to your computer and use it in GitHub Desktop.
Save evdokimovm/62d8e2ee86ea0e467eda8cbb708becf6 to your computer and use it in GitHub Desktop.
Get nth byte of integer
// Get nth byte of integer
// https://stackoverflow.com/a/7787433/5526354
int x = (number >> (8*n)) & 0xff;
# Get nth byte of integer
# https://stackoverflow.com/a/32695821/5526354
target = 0xd386d209
n = 0 # 0th byte
goal = 0xFF << (8 * n)
print hex((target & goal) >> (8 * n))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment