+ 4

Hi guys can I have the result of bitwise operators without turning the operands into the binary mod?

9th Jun 2019, 11:34 PM
Mbengue Mbor
Mbengue Mbor - avatar
11 Respostas
+ 8
Mbengue Mbor In case you weren't aware, I wanted to mention those challenges aren't a real test of your knowledge or measure of your skill. Nor are those challenges any reflection of good coding practices. Actually, quite the opposite. I would likely fire anyone who writes code like many of the brain teaser nonsense garbage used in those challenges. 😉 So, don't worry so much that your brain can't compute obscure expression statements like an overclocked 8-bit 6502 CPU. 😜 It's not required to be a brilliant programmer. đŸ€“
10th Jun 2019, 5:23 PM
David Carroll
David Carroll - avatar
+ 7
Well, yes print(25<<3) print(16&5) print(89|14) print(49^26) print(~17)
10th Jun 2019, 5:37 AM
Anna
Anna - avatar
+ 7
đŸ€Šâ€â™‚ïžđŸ€·â€â™‚ïž Anna I guess you went too far with your answer after the very first line "Well, yes" đŸ˜‚đŸ€Ł
10th Jun 2019, 12:44 PM
David Carroll
David Carroll - avatar
+ 6
? Then don't use it
10th Jun 2019, 12:16 PM
Anna
Anna - avatar
+ 6
So you want to know how the bitwise operators work? You can't do most of them in your head unless your IQ is at least 148
10th Jun 2019, 12:58 PM
Anna
Anna - avatar
+ 6
Everyone probably knows this, but in the off chance it benefits someone... Instead of actually writing them in binary, it's faster for me to break them into powers of 2. Let me explain with an example. 89 | 14 = (64+16+8+1) | (8+4+2) (for OR, we remove the duplicates) = 64+16+8+1 + 4+2 = 89+6 = 95 Similarly for 89 & 14, the answer is 8 because that's the only one that occurs in both. With some practice, it's possible to do this in your head. Though I can't say I'd appreciate these questions in the Challenges.
10th Jun 2019, 1:40 PM
Kishalaya Saha
Kishalaya Saha - avatar
+ 3
I know these two only since it's impossible to know all: x<<y = x*(2**y) x>>y = x/(2**y)
10th Jun 2019, 1:04 PM
Mo Hani
Mo Hani - avatar
+ 2
I mean in the challenge if I must give the answer of print (25<<3) or print(16&5) in few seconds
10th Jun 2019, 12:51 PM
Mbengue Mbor
Mbengue Mbor - avatar
+ 2
Thanks I know how to evaluate them but I have a luck of time in the challenges
10th Jun 2019, 1:18 PM
Mbengue Mbor
Mbengue Mbor - avatar
+ 2
Thank you
10th Jun 2019, 2:34 PM
Mbengue Mbor
Mbengue Mbor - avatar
+ 1
Thanks but I don't say the print function
10th Jun 2019, 11:39 AM
Mbengue Mbor
Mbengue Mbor - avatar