python being python doesnt use !, instead thats a bitwise operation. not is not in python. also beware of the walking r/unexpectedfactorial people, they will tear you apart
Yeah, I understood that, I intended my question more as "couldn't you still say that this is not?"
Also, from a quick google, it looks like ! isn't a bitwise not in python but ruther ~ is. And the way google describes it sounds like it's implemented to essentially be -x-1 for integers, just like it would act on a standard length int.
Funnily enough, notxorandxor_eq, orand_eqor_eq, not_eqbitandbitor have been keywords basically forever, yet they're never reused anywhere else they could be used. Heck, they didn't even use not as a way to invert keywords (e.g., using namespace Foo; not using Foo::Bar; to use all but one member of a namespace). I half thing the committee forgot the keywords even exit.
Can still be useful for debugging, since it's a quick-and-dirty way to make something assert-compatible without needing any other includes or code. Sometimes sees use in compile-time testing, too, since 0-length arrays are invalid; this is mostly solved by static_assert, but I think it still comes up from time to time?
In c++, the exclamation mark can only be placed before expressions, not after. For examle, !(x > 5) is valid syntax and is evaluated as true whenever x <= 5. But (x > 5)! is not a thing in c++
I did not negate anything, I just placed the explanation mark before the sentence instead of at the end of it. Before the entire sentence, not just "only"
17
u/Puzzleheaded_Study17 Mar 12 '26
How is this a cpp thing? basically every programming language has ! to mean not
5
u/csabinho Mar 12 '26
It's wrong. "!!" means the same as nothing. Unless you want to bring a random number to 1 or 0.
8
u/Pleasant-Ad-7704 Mar 12 '26
!Only if you put the exclamation mark before the sentence
1
u/conundorum Mar 21 '26
I'm surprised you aren't mentally reducing
!!to "convert tobool". Howassertive are you?