music
OSdata.com: programming text book 

OSdata.com

Boolean programming

summary

    This chapter looks at Boolean programming in the context of the decision structure. Bit-wise Boolean operations are covered in a separate chapter..

free computer programming text book project

table of contents
If you like the idea of this project,
then please donate some money.
more information on donating

Google

stub section

    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.

Boolean programming

    This chapter looks at Boolean programming in the context of the decision structure. Bit-wise Boolean operations are covered in a separate chapter..

    Boolean algebra is named for George Boole, who introduced the ideas in the 1854 work “An Investigation of the Law of Thought”. Claude Shannon showed the application of Boolean algebra to switching circuits in the 1938 work “Symbolic Analysis of Relay and Switching Circuits”.

    Please note the differences between a logical Boolean operation, an integer Boolean operation, and a bit-wise Boolean operation. Note that terminology varies, so you will eventually see references using these terms different than presented here.

    In the case of a logical Boolean operation, the result is a logical BOOLEAN type of either TRUE or FALSE. Some languages, such as C, do not have a built-in Boolean type. There are several different and incompatible encodings for TRUE and FALSE (see table below).

    In the case of an integer Boolean operation, the operation is performed on the two integers as whole numbers. The result can be inaccurate if the integer is not in a specified form (the legal options usually being [ZERO and ONE] or [ZERO and NEGATIVE ONE]. This works best with -1 and 0 as TURE and FALSE (or vice versa). There are several different and incompatible encodings for TRUE and FALSE (see table below).

some
languages
 TRUE FALSE
C 1 0
C non-zero zero
  negative zero or
positive
  -1 0
  0 1
JavaScript   ""
(empty string)
Ruby all other values false
nil

    in the case of a bit-wise Boolean operation, a logical operation is performed on each corresponding bit of the two bit strings (or two single bits). Note that a NOT is performed on only a single bit string or single bit.

    SQL allows for four Boolean values: TRUE, FALSE, UNKNOWN, and NULL (but allowed vendors to combine unknown and null into a single entity).

Stanford C essentials

    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.

Logical Operators

    The value 0 is false, anything else is true. The operators evaluate left to right and stop as soon as the truth or falsity of the expression can be deduced. (Such operators are called “short circuiting”) In ANSI C, these are furthermore guaranteed to use 1 to represent true, and not just some random non-zero bit pattern. However, there are many C programs out there which use values other than 1 for true (non-zero pointers for example), so when programming, do not assume that a true boolean is necessarily 1 exactly.

!      Boolean not (unary)
&&      Boolean and
||      Boolean or

    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.

end of Stanford C essentials

Ada

    “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-Europe’s 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-Europe’s Ada Reference Manual: Introduction: Language Summary See legal information

chapter contents


free music player coding example

    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

view text book
HTML file

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
previous page next page

free computer programming text book project

Building 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,
then please donate some money.

send donations to:
Milo
PO Box 1361
Tustin, California 92781

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)

more information on donating

Some or all of the material on this web page appears in the
free downloadable college text book on computer programming.


Google


Made with Macintosh

    This web site handcrafted on Macintosh computers using Tom Bender’s Tex-Edit Plus and served using FreeBSD .

Viewable With Any Browser


    †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, 2012 Milo

    Created: December 5, 2010

    Last Updated: February 21, 2012


return to table of contents
free downloadable college text book

previous page next page
previous page next page