+ 1

ASSIGNMENT OPERATORS

How do these assignment operators work in C++ (kindly use examples): a)&= b)|= c)^= d)<<= e)>>=

14th Sep 2022, 6:01 PM
zighetamara
6 odpowiedzi
+ 1
do you need assembly equivalent?
14th Sep 2022, 6:15 PM
Prashanth Kumar
Prashanth Kumar - avatar
+ 1
These are all basically bitwise assignment operators 1. A &= B is equal to A = A & B (AND) 2. A |= B is equal to A = A | B (OR) 3. A ^= C is equal to A = A ^ B (XOR) 4. A <<= B means A = A << B (Binary Left Shift) 5. A =>> B means A = A >> B (Binary Right Shift) Examples : Left hand side = A Right hand side = B 1. 255 &= 128= 128 2. 255 |= 10 = 255 3. 255 ^= 100 = 150 4. 1 <<= 1 = 2 (0b00000010) 5. 128 >>= 1 = 64 (0b01000000)
16th Sep 2022, 4:53 PM
CoderBittu
CoderBittu - avatar
0
Yaroslav Vernigora your links are really helpful before I knew some but not all of them but now ,it all clears.
14th Sep 2022, 6:25 PM
Samarendra Singh
Samarendra Singh - avatar
0
On!oN have you tried to search for such links yourself? I found them in a search engine in five seconds. or are search engines not running in your country?
14th Sep 2022, 6:32 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
@Prashanth Kumar if it will clearly explain how the above operators work.
15th Sep 2022, 5:32 AM
zighetamara