Looking at some code I noticed that another dev had changed every instance of true to !false. Why would you do that? thx
+4
A:
I have no idea and I've been writing C++ for a while. I suspect whatever he reasons were they weren't good ones.
Mike McQuaid
2009-07-30 09:35:29
+1 for bad reasons. What is it about booleans that makes people distrust them?
Steve Gilham
2009-07-30 09:38:42
Booleans can be false too!
kenny
2009-07-30 10:14:44
@Steve: the fact that they didn't originally exist in C.
Mike McQuaid
2009-07-30 14:25:05
A:
I do not know actually but may be TRUE is not 1 (any thing > 0) and FALSE is zero so "not false" = 1 so he will be in safe place
Ahmed Said
2009-07-30 09:37:54
Sorry - should've been clear - the datatypes are C++ bools, afaik these are either true=1 or false=0.
Cokes
2009-07-30 09:39:51
I remember that there is data type in windows called BOOLEAN.Boolean variable (should be TRUE or FALSE).This type is declared in WinNT.h as follows:typedef BYTE BOOLEAN;
Ahmed Said
2009-07-30 09:54:15
Agreed. He was probably once told to use !FALSE when using the TRUE/FALSE macros, but I see no reason to do so with a proper bool data type.
Roel
2009-07-30 16:06:46
+3
A:
I think this is a historical thing. IIRC there was a problem on some C/C++ compilers knowing what the compiler would use to represent as true. You can know false is zero hence !false will be whatever the current ABI will have as true.
Generically this is redundant but there are a few special case where it is useful but I can't think of one.
David Allan Finch
2009-07-30 09:51:12
+1
A:
maybe he got so many true and false in his code and he wanted to reverse it easily, he can just use his editor's search and replace,
newbie
2009-07-30 10:07:53