C (programming language)/Tutorials: Difference between revisions

From Citizendium
Jump to navigation Jump to search
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...)
 
imported>Chris Day
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{subpages}}
=C Programming Language Tutorials=
=C Programming Language Tutorials=




==Truth values and Iverson Bracket==
==Truth values in C and the 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.
Truth values in C can be simple integers. The C programming language is set up nicely to support the Iverson Bracket set notation. Iverson proposed that truth values should be numerical with true=1 and false=0. Actually 0=false in C and all non-zero values are True, even -1 is true in C.
zero    : false
non-zero : true


The following calculates the maximum of two numbers using an Iverson bracket formula using the notation in C.
The following calculates the maximum of two numbers using an Iverson bracket formula in C.
The traditional Iverson bracket notation in algebra: [a>b] gives 1 or 0.


  max = (a>=b)*a + (b<a)*b;
  max = (a>=b)*a + (b<a)*b;     in C
============================= lets caluculate using 6 and 7
============================= lets calculate using 6 and 7
  7  = (6>=7)*6 + (7<6)*7
  7  = (6>=7)*6 + (7<6)*7     in algegra

Latest revision as of 03:08, 7 January 2009

This article is developing and not approved.
Main Article
Discussion
Related Articles  [?]
Bibliography  [?]
External Links  [?]
Citable Version  [?]
Tutorials [?]
 
Tutorials relating to the topic of C (programming language).

C Programming Language Tutorials

Truth values in C and the Iverson Bracket

Truth values in C can be simple integers. The C programming language is set up nicely to support the Iverson Bracket set notation. Iverson proposed that truth values should be numerical with true=1 and false=0. Actually 0=false in C and all non-zero values are True, even -1 is true in C.

zero     : false
non-zero : true

The following calculates the maximum of two numbers using an Iverson bracket formula in C.

The traditional Iverson bracket notation in algebra: [a>b] gives 1 or 0.
max = (a>=b)*a + (b<a)*b;     in C
============================= lets calculate using 6 and 7
7   = (6>=7)*6 + (7<6)*7      in algegra