music |
OSdata.com |
Booleans
summary
Representing Boolean values in a computer.
free computer programming text book projecttable of contents
|
music |
OSdata.com |
Representing Boolean values in a computer.
free computer programming text book projecttable of contents
|
This subchapter is a stub section. It will be filled in with instructional material later. For now it serves the purpose of a place holder for the order of instruction.
Professors are invited to give feedback on both the proposed contents and the propsed order of this text book. Send commentary to Milo, PO Box 1361, Tustin, California, 92781, USA.
Representing Boolean values in a computer.
The Boolean type is used to store Boolean values. Boolean values are TRUE or FALSE. Some programming languages have a specific Boolean type and others dont. In languages that dont have a specific Boolean type, some other system must be used. In PL/I a bit is set to either '0'B or '1'B. In COBOL a text word is used, such as the combination of 'TRUE' and 'FALSE' or 'YES' and 'NO'. In C an integer is used and the the Boolean values are represented by the combination of one for TRUE and 0 for FALSE.
In ALGOL 68 the Boolean mode is declared with the reserved word bool.
bool SimpleFlag;
FORTRAN IV introduced the LOGICAL type and the truth literals .TRUE. and .FALSE., as well as the logical operators .AND., .OR., and .NOT., and the FORMAT control characterL.
LOGICAL L1, L2, L3
LISP uses the empty list for FALSE and any other value for TRUE.
In Pascal the Boolean type is declared with the reserved word boolean.
var Flag: boolean;
PL/I does not have an explicit Boolean type, using a single bit instead. PL/I Boolean expressions (such as in IF and WHILE expressions) evaluate to a single bit.
Python includes the core built-in type bool.
bool(x)
Evaluates the argument x and returns False if the argument x evaulates to flase or returns True if the argument evaulates as true.
bool is a subclass of int.
The only two instances of type bool are False and True. False is also an integer equal to 0 and True is also an integer equal to 1. str(True) evaluates to 'True' and str(False) evaluates to 'False'.
SQL allows for four Boolean values: TRUE, FALSE, UNKNOWN, and NULL (but allowed vendors to combine unknown and null into a single entity).
Stanford CS Education Library This [the following section until marked as end of Stanford University items] is document #101, Essential C, in the Stanford CS Education Library. This and other educational materials are available for free at http://cslibrary.stanford.edu/. This article is free to be used, reproduced, excerpted, retransmitted, or sold so long as this notice is clearly reproduced at its beginning. Copyright 1996-2003, Nick Parlante, nick.parlante@cs.stanford.edu.
C does not have a distinct boolean type-- int is used instead. The language treats integer 0 as false and all non-zero values as true. So the statement
i = 0;
while (i - 10) {
...
will execute until the variable i takes on the value 10 at which time the expression (i - 10) will become false (i.e. 0). (well see the while() statement a bit later)
Stanford CS Education Library This [the above section] is document #101, Essential C, in the Stanford CS Education Library. This and other educational materials are available for free at http://cslibrary.stanford.edu/. This article is free to be used, reproduced, excerpted, retransmitted, or sold so long as this notice is clearly reproduced at its beginning. Copyright 1996-2003, Nick Parlante, nick.parlante@cs.stanford.edu.
31 Every object in the language has a type, which characterizes a set of values and a set of applicable operations. The main classes of types are elementary types (comprising enumeration, numeric, and access types) and composite types (including array and record types). :Ada-Europes Ada Reference Manual: Introduction: Language Summary See legal information
32/2 An enumeration type defines an ordered set of distinct enumeration literals, for example a list of states or an alphabet of characters. The enumeration types Boolean, Character, Wide_Character, and Wide_Wide_Character are predefined. :Ada-Europes Ada Reference Manual: Introduction: Language Summary See legal information
Coding example: I am making heavily documented and explained open source code for a method to play music for free almost any song, no subscription fees, no download costs, no advertisements, all completely legal. This is done by building a front-end to YouTube (which checks the copyright permissions for you).
View music player in action: www.musicinpublic.com/.
Create your own copy from the original source code/ (presented for learning programming).
return to table of contents
free downloadable college text book
Because I no longer have the computer and software to make PDFs, the book is available as an HTML file, which you can convert into a PDF.
previous page | next page |
Tweets by @osdata |
free computer programming text book projectBuilding a free downloadable text book on computer programming for university, college, community college, and high school classes in computer programming. If you like the idea of this project, Supporting the entire project: If you have a business or organization that can support the entire cost of this project, please contact Pr Ntr Kmt (my church) free downloadable college text book on computer programming. |
This web site handcrafted on Macintosh computers using Tom Benders Tex-Edit Plus and served using FreeBSD .
UNIX used as a generic term unless specifically used as a trademark (such as in the phrase UNIX certified). UNIX is a registered trademark in the United States and other countries, licensed exclusively through X/Open Company Ltd.
Names and logos of various OSs are trademarks of their respective owners.
Copyright © 2010, 2011 Milo
Created: December 12, 2010
Last Updated: January 14, 2011
return to table of contents
free downloadable college text book
previous page | next page |