Tag: bitwise
-
Swift: Advanced operator – bitwise XOR operator
Swift provides XOR ( ^ ) operator which compares two numbers and returns a new number in which the bits are set to 1 when the corresponding bits in the numbers are not equal and bits are set to 0 when the bits in those numbers are same.
-
Swift: Advanced operator – bitwise OR operator
Swift provides bitwise OR ( | ) operator. The OR operator returns a new number with bits set to 1 only when either of the bits present in the two numbers is equal to 1.
-
Swift: Advanced operator – bitwise AND operator
Swift provides bitwise AND ( & ) operator. The AND operator combines the bits of two numbers and returns a new number with bits set to 1 only when both the bits in those numbers are equal to one.
-
Swift: Advanced operator – bitwise NOT operator
Swift provides advanced operators such a s bitwise operators. The bitwise NOT ( ~ ) operator inverts all bits in a number.