+ 16

Weird Part of C++ Logical Operators

While I was writing code in c++ I accidentally wrote the keyword 'and' instead of && since I did python a few days ago and to my surprise, the keyword got highlighted! I thought this was a bug or something until I found this: https://stackoverflow.com/questions/2376448/the-written-versions-of-the-logical-operators Share any more of this weird stuff if you have any!

13th Dec 2017, 1:38 PM
Cool Codin
Cool Codin - avatar
5 Answers
+ 9
Hi @Cool Codin Instead of putting a title "Did you know this?!", it's better to set a proper title such as "Weird part of C++ and operator". This could definitely help you find the answers faster, rather then meaningless title which won't be helping you at all. 😊 It also helps others to find the similar question and solution easier later. Cheers 😊 Edited: thanks for the changes @Cool 👍🏼
13th Dec 2017, 1:36 PM
CalviŐ˛
CalviŐ˛ - avatar
+ 9
@Calvin Thanks! Updated it!
13th Dec 2017, 1:38 PM
Cool Codin
Cool Codin - avatar
+ 4
great discovery. but my advice to you is to never write a logical/bitwise operator in word (and, or, xor, not) because they will still be converted to (&, |, ^, ~) respectively. this Is because using word formats will decrease performance. so use the symbols instead. happy coding.
13th Dec 2017, 4:05 PM
Germain F
Germain F - avatar
+ 1
32 bit
7th Jan 2018, 11:48 AM
Xander Keylis
0
Would it really matter?? If it works, it works for a reason, no? The only way you will really know, is to compile and run a test program, whilst using a timer or/and a debugger. But as you have stated, it will all get converted in the end, so performance shouldn't be a problem when it's all compiled to binary, or do I have that completely wrong ? However I do know, using AND, OR etc isn't anything new to c++,
14th Dec 2017, 5:31 PM
John Sons
John Sons - avatar