Last active
December 26, 2017 01:12
-
-
Save reza-ryte-club/02034f0eb1f835c10e2feac0149d77a5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var bitOne = 0b00000001 | |
var maskingBit = 0b00000000 | |
// Retrieve the state of the bit of the first digit from right side of bitOne | |
print(String(bitOne|maskingBit, radix: 2)) // Print 1, which indicates the first digit from the right of bitOne is 1 | |
// Turn on the first digit of bitOne no matter what the previous bit was | |
bitOne = bitOne|maskingBit | |
// Turn off the first digit of bitOne | |
bitOne = bitOne&maskingBit | |
// Change the first digit of bitOne | |
maskingBit = 0b00000001 | |
bitOne = bitOne ^ maskingBit | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment