Skip to content

Instantly share code, notes, and snippets.

@gumienny
Last active December 5, 2018 19:03
Show Gist options
  • Save gumienny/507caab23f89f65f65015e0677a7290f to your computer and use it in GitHub Desktop.
Save gumienny/507caab23f89f65f65015e0677a7290f to your computer and use it in GitHub Desktop.
  • parzystość liczby x & 1
  • sprawdzenie czy dwa int-y mają przeciwny znak (x ^ y) < 0
  • dodanie 1 do int-a -~x
  • swap
x = x ^ y; // x^= y;
y = x ^ y;
x = x ^ y;
  • wyłączenie k-tego bitu x & (~(1 << (k - 1)))
  • włącznie k-tego bitu x | (1 << (k - 1))
  • sprawdzenie czy k-ty bit jest włączony (x & (1 << (k - 1))) != 0
  • toogle k-th bit x ^ (1 << (k - 1))
  • sprawdzenie czy x jest potęgą liczby 2 x & (x - 1) == 0
  • ascii upper to lower char(ch | ' ')
  • ascii lower to upper char(ch & '_')
  • ascii invert case char(ch ^ ' ')
  • pozycja litery w alfabecie ch & 31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment