C (programming language)/Tutorials
Jump to navigation
Jump to search
C Programming Language Tutorials
Truth values and Iverson Bracket
The C programming language is set up nicely to support the Iverson Bracket set notation. Iverson proposed that truth values are numerical with true=1 and false=0. Actually 0=false in C and all non-zero values are True, even -1.
The following calculates the maximum of two numbers using an Iverson bracket formula using the notation in C.
max = (a>=b)*a + (b<a)*b;
============================= lets caluculate using 6 and 7
7 = (6>=7)*6 + (7<6)*7