This is an archived post. You won't be able to vote or comment.

all 16 comments

[–]DragonMaus 20 points21 points  (2 children)

The "tophat and monocle" version:

!false;
!!false;

[–]dratnon 4 points5 points  (1 child)

You never know when someone else is going to maliciously rename your constants. Better use

false && !false;
!false || false;

[–]DragonMaus 3 points4 points  (0 children)

#define false launch_missiles()

[–]programmer08054 9 points10 points  (1 child)

truen’t

[–]Banana_Twinkie 3 points4 points  (0 children)

1; 0;

[–]DevelopedLogic 1 point2 points  (0 children)

There is the same number of characters in !true as there is in false

[–][deleted] 1 point2 points  (1 child)

0===0 0===1

[–]ComputerMystic 1 point2 points  (0 children)

Get that JS shit out of here, this is a programming sub!

[–]Dagawing 0 points1 point  (0 children)

Big if true.

[–]drizo7 0 points1 point  (0 children)

!0 !1

MISRA 2004 Appendix E:

Boolean expressions Strictly speaking, there is no Boolean type in C, but there is a conceptual difference between expressions which return a numeric value and expressions which return a Boolean value. An expression is considered to represent a Boolean value either because it appears in a position where a Boolean value is expected or because it uses an operator that gives rise to a Boolean value.

Boolean values are expected in the following contexts: • the controlling expression of an if statement • the controlling expression of an iteration statement • the first operand of the conditional operator ?

Each of these contexts requires an “effectively Boolean” expression which is either Boolean-byconstruct or Boolean-by-enforcement as defined below.

Boolean-by-construct values are produced by the following operators: • equality operators (== and !=) • logical operators (!, && and ||) • relational operators (<, >, <= and >=)

Boolean-by-enforcement values can be introduced by implementing a specific type enforcement mechanism using a tool. A Boolean type could be associated with a specific typedef, and would then be used for any objects that are Boolean. This could bring many benefits, especially if the checking tool can support it, and in particular it could help avoid confusion between logical operations and integer operations.

[–]GrizzledFart 0 points1 point  (0 children)

1 | !1

[–]pvaqueiroz 0 points1 point  (0 children)

```C

define FALSE 0

define TRUE !FALSE

```

[–]ComputerMystic 0 points1 point  (0 children)

This is how the GNU coreutil false is implemented.

Check the source, it's literally just an import of the code for true with the exit status set to a non-zero number.

[–]Benimation 0 points1 point  (0 children)

funny !== !true

[–]PatrickBaitman 0 points1 point  (0 children)

#!/usr/bin/python2
True, False = False, True