Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dumindu/ab4e2fbe4d5c2233e103 to your computer and use it in GitHub Desktop.
Save dumindu/ab4e2fbe4d5c2233e103 to your computer and use it in GitHub Desktop.
let mut a = 2;
a += 5; //2 + 5 = 7
a -= 2; //7 - 2 = 5
a *= 5; //5 * 5 = 25
a /= 2; //25 / 2 = 12 not 12.5
a %= 5; //12 % 5 = 2
a &= 2; //10 && 10 -> 10 -> 2
a |= 5; //010 || 101 -> 111 -> 7
a ^= 2; //111 != 010 -> 101 -> 5
a <<= 1; //'101'+'0' -> 1010 -> 10
a >>= 2; //101̶0̶ -> 10 -> 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment