C (programming language)/Tutorials

From Citizendium
< C (programming language)
Revision as of 21:12, 22 April 2008 by imported>Eric Evers (New page: =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 tr...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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