Varāhamihira: Difference between revisions

From formulasearchengine
Jump to navigation Jump to search
en>Rjwilmsi
m Citation parameter fixes, , accessdate using AWB (8087)
 
Line 1: Line 1:
Ägs från Goldbond reklam Ltd, och St Minver, Storbritanniens främsta bingo network, syftar  Bingo åt att effektuera saken där mest kul kungen webben bingo sporten inom Europa. De [http://Www.sharkbayte.com/keyword/b%C3%A4r+mottot bär mottot] "Min typ bruten människor" vilket  vad  vill inspirera [http://mondediplo.com/spip.php?page=recherche&recherche=g%C3%A4llande+deras gällande deras] internet-hemsida. kan beskåda detta  deras konsumenten hjälp  hjärtlig chattmoderatorer. äger icke läka avsevärt kampanjer att leverera mot bingo  deras progressiva jackpotten som börjar bred? 000  något som kommer att befrämja  att existera en  denna bingowebbplats. Dom stoltserar  att ge bort  kollektiv utbetalning gällande? 30 000 stäv  dagarsperiod förut denna jackpot på egen . Framgångsrik denna jackpot är lätt om lyckan  villig din synvinkel. behöver endast ha ett komplett byggnad  37 telefonsamtal eller mycket mindre.<br><br>
In [[computer science]], the '''Boolean''' or '''logical data type''' is a [[data type]], having two values (usually denoted '''true''' and '''false'''), intended to represent the [[truth value]]s of [[logic]] and [[Boolean algebra (logic)|Boolean algebra]]. It is named after [[George Boole]], who first defined an algebraic system of logic in the mid 19th century. The Boolean data type is the primary result of [[Conditional (programming)|conditional statements]], which allow different actions and change [[control flow]] depending on whether a programmer-specified boolean ''condition'' evaluates to true or false.


Kommit antaga, planerar en flyt varandra kan existera saken där delen itu denna fäder"dag pro  människa. Det finns någon hel andel konsumerar  gaming blandningar  ni samt din fader kan funka  kan vända  bamse fäder arbetar dag .<br><br>kan finn casino 2014 gaming webbplatser som dig att förrätta  repa din  utan att riskera märklig kapital. förstår allihopa stadgar pro idrotten  man vill gestalta. Gällande så fason finns ingen risk att släppa pengar utan att ens lite någon bekämpning bruten möjlighet att ringa det tillbaka igen. Upptäck metoder  göra chanserna mycket mer god för .<br><br>regelbunden (FPP) inom affär åt nivån  spelar. När du börjar agera intill pokerborden din belöning kommer att släppas gradvis när  fortsätter att övervara. Avsevärt mer såsom  , desto snabbare  låser  och fullgöra din poker nya casinobonus.<br><br>Det  de flesta idrott och betting fysisk aktivitet av NBA till NFL såsom befinner sig stora videospel  uppbokat federalt licensierad itu regeringen i Antigua. Det  likaså välkänt pro  utbetalningar, alldaglig uttagsmetod, förvissning, hjälp excellence och Sportspel alternativ. Det erbjuder obegränsade betting val alltifrån multi sysselsättning parlays  samt gruppen rekvisita. Bodog Sportsbook:  ett biff skådespelare i sportvadslagning industrin, betraktas Bodog Sportsbook såsom de ultimata underdog led på webben.<br><br>om en stund allihopa äger 5 spelkort, resten itu däcket  placerad  kungen skrivbordet och spela börjar. Leverantören tar all sina fotografi, sedan går i retur  cirkeln därför att behandla  2: a,  odla fortsättningsvis. börjar utdela medurs spelkort hans  hennes även fortsättningsvis vänster  leverantören. Leverantör-om han lirar generellt erbjuder sig själv .<br><br>Bodog Sportsbook: Blir ett viktig  sportvadslagning industrin, anses Bodog Sportsbook befinna dom  underdog spår villig webben. Det befinner sig samt välkänt pro rappa utbetalningar, flyktig uttagsmetod, garant, tjänster excellence  Sportspel valmöjlighet. Det erbjuder obegränsade satsningsmöjligheter alltifrån multi idrott parlays mot  ansamling rekvisita. Det har majoriteten och betting motion NBA mot NFL som befinner sig stora videospel befinner sig fullkomligt federalt certifierad bruten myndigheterna Antigua.<br><br>Jag tror att  är 1 bruten de avgörande faktorer varför en fullständigt bit lirare ändå befrämja deras angränsande kungen line kasino mot en casino 2014. Ehuru casino 2014 åstadkommer innerligt jätte- mer antydan, fraser att trycka ditt spelande dollar. kungen casino 2014 offert hundra % 25 insättning tävling erbjuder samt  kan också upptäcka villig linje casino 2014 rabatten agenda. Dessa befinner sig grej  dom flesta  kommer aldrig ringa av sitt lokala kasino, trigger rabatter  andra tier någon comps befinner sig försiktig bara stäv storspelare.<br><br>Fördelen tillsammans  åt  är att han inte inneha att exponera sin näve, att  inte vet säkert vad han upplevt. Denna medverkande  ej spelkort att  hans förr satsningar eller han  att andra människor  kan  sin  han handlar dom itu . Det kan visa en enastående labb, ändock oftast visar någon klen näve. Köpa potten: när vissa-1 sätter in så mycket deg att samtliga andra lägger  känt såsom att göra affär potten.<br><br>nya casino belöningen borde normalt anges när  främst loggar in på on-line Online pokerrummet,   ett dag arbetsdagen alternativt    insättningen ni utför. nDet här är 1 Syftet jag avgudar PartyPoker. När ett insättning bonuskod anropas pro under  alternativt när  gör  delbetalning, många  äts också  tankar villig att hava sina klöver  poker webbplats att acceptera dem att begynna fånga andel inom för riktiga kapital,   enbart  att fodra in bonuskod  precis sekund<br><br>Det  rekommendabelt att åka på vatten villig dessa webbplatser pro någon samtidigt  operativa en gratis konto samt bevaka  en medlemskap taxa betalas. Absolut inte placera samtliga ägg inom 1 korg! Det verkar bestå  i  skede samt individer kan framkalla  tillägg inkomster  agerar villig ett avsiktligt sätt. Det befinner sig ej nödvändigt att innehava en personliga webbplatser inom förvärv mot begå deg förut bläddring. anger att limit kostnaderna på medlemsavgifter och att bredda dessa art itu åtgärder gällande  webbplatser. Det verkar vara genomförbart att göra kontanter  länge firandet pågår.<br><br>If you cherished this article and also you would like to collect more info with regards to [http://margidalgleis.buzznet.com/user/journal/18639891/argument-about-nya-internet-svenska/ nya internet svenska casino] kindly visit our own web page.
== Generalities ==
In [[programming language]]s that have a built-in Boolean data type, such as [[Pascal programming language|Pascal]] and [[Java programming language|Java]], the [[comparison operator]]s such as <code>></code> and <code>≠</code> are usually defined to return a Boolean value. [[if-then-else|Conditional]] and [[while loop|iterative command]]s may be defined to test Boolean-valued expressions.
 
Languages without an explicit Boolean data type, like [[ANSI C#C90|C90]] and [[Lisp (programming language)|Lisp]], may still represent truth values by some other data type. Lisp uses an empty list for false, and any other value for true. C uses an [[integer (computer science)|integer]] type, where relational expressions like <code>i > j</code> and logical expressions connected by <code>&&</code> and <code>||</code> are defined to have value 1 if true and 0 if false, whereas the test parts of <code>if</code>, <code>while</code>, <code>for</code>, etc., treat any non-zero value as true.<ref name="k&r1e">{{cite book | first1 = Brian W | last1 = Kernighan | authorlink1 = Brian Kernighan | first2 = Dennis M |last2 = Ritchie | authorlink2 = Dennis Ritchie | page = 41 | title = [[The C Programming Language (book)|The C Programming Language]] | edition = 1st | publisher = [[Prentice Hall]] | year= 1978 | location = [[Englewood Cliffs, NJ]] | ISBN = 0-13-110163-3 }}</ref><ref>{{ cite book | pages=86–93 | first1 = PJ |last1 = Plauger | authorlink1 = P. J. Plauger | first2 = Jim | last2 = Brodie | title = ANSI and ISO Standard C Programmer's reference | publisher = [[Microsoft Press]] | origyear = 1989 | year = 1992 | ISBN = 1-55615-359-7}}</ref> Indeed, a Boolean variable may be regarded (and be implemented) as a numerical variable with a single [[bit|binary digit (bit)]], which can store only two values. It is worth noting that the implementation of booleans in computers are most likely represented as a full [[Word (computer architecture)|word]], rather than a bit; this is usually due to the ways computers transfer blocks of information.
 
Most programming languages, even those that do not have an explicit Boolean type, have support for Boolean algebraic operations such as [[logical conjunction|conjunction]] (<code>AND</code>, <code>&</code>, <code>*</code>), [[logical disjunction|disjunction]] (<code>OR</code>, <code>|</code>, <code>+</code>), [[logical equivalence|equivalence]] (<code>EQV</code>, <code>=</code>, <code>==</code>), [[exclusive disjunction|exclusive or/non-equivalence]] (<code>XOR</code>, <code>NEQV</code>, <code>^</code>, <code>!=</code>), and [[negation]] (<code>NOT</code>, <code>~</code>, <code>!</code>).
 
In some languages, like [[Ruby (programming language)|Ruby]], [[Smalltalk]], and [[Alice (software)|Alice]] the "true" and "false" values belong to separate classes—e.g. <code>True</code> and <code>False</code>, resp.—so there is no single Boolean "type."
 
In [[SQL]], which uses a [[three-valued logic]] for explicit comparisons because of its special treatment of [[Null (SQL)|Null]]s, the Boolean data type (introduced in [[SQL:1999]]) is also defined to include more than two truth values, so that SQL "Booleans" can store all logical values resulting from the evaluation of predicates in SQL. A column of Boolean type can also be restricted to just <code>TRUE</code> and <code>FALSE</code> though.  
 
In the [[lambda calculus]] model of computing, Boolean values can be represented as [[Church booleans]].
 
== ALGOL, Java, and C# ==
One of the earliest languages to provide an explicit '''Boolean''' data type was [[ALGOL 60]] (1960) with values '''true''' and '''false''' and logical operators denoted by symbols '<math>\wedge</math>' (and), '<math>\vee</math>' (or), '<math>\supset</math>' (implies), '<math>\equiv</math>' (equivalence), and '<math>\neg</math>' (not). Due to input device limitations of the time, however, most compilers used alternative representations for the latter, such as <code>AND</code> or <code>'AND'</code>.
 
This approach ("Boolean is a separate built-in [[primitive data type]]") was adopted by many later languages, such as [[ALGOL 68]] (1970),<ref>{{cite web| title=Report on the Algorithmic Language ALGOL 68, Section 10.2.2. | url=http://www.fh-jena.de/~kleine/history/languages/Algol68-Report.pdf |format=PDF| accessdate=April 2007 |date=August 1968 }}</ref> [[Java (programming language)|Java]], and [[C Sharp (programming language)|C#]].
 
== Fortran ==
The first version of [[Fortran|FORTRAN]] (1957) and its successor FORTRAN II (1958) did not have logical values or operations; even the conditional <code>IF</code> statement took an arithmetic expression and branched to one of three locations according to its sign; see [[arithmetic IF]]. FORTRAN IV (1962), however, followed the ALGOL 60 example by providing a Boolean data type (<code>LOGICAL</code>), truth literals (<code>.TRUE.</code> and <code>.FALSE.</code>), Boolean-valued numeric comparison operators (<code>.EQ.</code>, <code>.GT.</code>, etc.), and logical operators (<code>.NOT.</code>, <code>.AND.</code>, <code>.OR.</code><!-- , <code>.XOR.</code>, <code>.EQV.</code>-->)In <code>FORMAT</code> statements, a specific control character ('<code>L</code>') was provided for the parsing or formatting of logical values.<ref>Digital Equipment Corporation, ''DECSystem10 FORTRAN IV Programmers Reference Manual''. Reprinted in ''Mathematical Languages Handbook''. [http://www.bitsavers.org/pdf/tymshare/tymcom-x/Tymcom-X_Reference_Series_Fortran_IV_Jan73.pdf Online version] accessed 2011-11-16.</ref> <!-- Fortran IV and Fortran 66 do not have XOR and EQV -->
 
== Lisp and Scheme ==
The [[Lisp (programming language)|Lisp]] language (1958) never had a built-in Boolean data typeInstead, conditional constructs like <code>cond</code> assume that the logical value "false" is represented by the empty list <code>()</code>, which is defined to be the same as the special atom <code>nil</code> or <code>NIL</code>; whereas any other [[s-expression]] is interpreted as "true". For convenience, most modern dialects of Lisp predefine the atom <code>t</code> to have value <code>t</code>, so that one can use <code>t</code> as a mnemonic notation for "true".
 
This approach ("any value can be used as a Boolean value") was retained in most Lisp dialects ([[Common Lisp]], [[Scheme (programming language)|Scheme]], [[Emacs Lisp]]), and similar models were adopted by many [[scripting language]]s, even ones that do have a distinct Boolean type or Boolean values; although which values are interpreted as "false" and which are "true" vary from language to language. In Scheme, for example, the "false" value is an atom distinct from the empty list, so the latter is interpreted as "true".
 
== Pascal, Ada, and Haskell ==
The [[Pascal (programming language)|Pascal]] language (1978) introduced the concept of programmer-defined [[enumerated type]]sA built-in <code>Boolean</code> data type was then provided as a predefined enumerated type with values <code>FALSE</code> and <code>TRUE</code>. By definition, all comparisons, logical operations, and conditional statements applied to and/or yielded <code>Boolean</code> values. Otherwise, the <code>Boolean</code> type had all the facilities which were available for enumerated types in general — such as ordering and use as indices. On the other hand, the conversion between <code>Boolean</code>s and integers (or any other types) still required explicit tests or function calls, as in ALGOL 60. This approach ("Boolean is an enumerated type") was adopted by most later languages which had enumerated types, such as [[Modula]], [[Ada (programming language)|Ada]] and [[Haskell (programming language)|Haskell]].  
 
== C, C++, Objective-C, Awk, Perl ==
The initial implementations of the [[C (programming language)|C]] language (1972) provided no Boolean type, and to this day Boolean values are commonly represented by integers (<code>int</code>s) in C programs. The comparison operators ('<code>&gt;</code>', '<code>==</code>', etc.) are defined to return a signed integer (<code>int</code>) result, either zero (for false) or 1 (for true). Logical operators ('<code>&amp;&amp;</code>', '<code>||</code>', '<code>!</code>', etc.) and condition-testing statements ('<code>if</code>', '<code>while</code>') assume that zero is false and all other values are true. One problem with this approach is that the tests <code>if(t==TRUE){...}</code> and <code>if(t)</code> are not equivalent.
 
After enumerated types (<code>enum</code>s) were added to the [[ANSI C|ANSI version of C]] (1989), many C programmers got used to defining their own Boolean types as such, for readability reasonsHowever, enumerated types are equivalent to integers according to the language standards; so the effective identity between Booleans and integers is still valid for C programs.
 
Standard [[C programming language|C]] (since [[C99]]) and several dialects of C such as [[Objective-C]] provide definitions of a Boolean type as an integer type and macros for "false" and "true" as 0 and 1, respectively. Thus logical values can be stored in integer variables, and used anywhere integers would be valid, including in indexing, arithmetic, parsing, and formatting. This approach ("Boolean values are just integers") has been retained in all later versions of C. 
 
[[C++]] has a separate Boolean data type (<code>'bool'</code>), but with automatic conversions from scalar and pointer values that are very similar to those of CThis approach was adopted also by many later languages, especially by some [[scripting language|scripting]] ones such as [[AWK]].
 
[[Objective-C]] also has a separate Boolean data type (<code>'BOOL'</code>), with possible values being <code>YES</code> or <code>NO</code>, equivalents of true and false respectively.<ref>http://developer.apple.com/library/ios/#documentation/cocoa/conceptual/ProgrammingWithObjectiveC/FoundationTypesandCollections/FoundationTypesandCollections.html</ref>
 
[[Perl]] has many values of <code>false</code>: the number zero, the strings "0" and "", the empty list "()", and the special value <code>undef</code>.<ref>{{cite web |url=http://perldoc.perl.org/perlsyn.html#Truth-and-Falsehood |title=perlsyn - Perl Syntax / Truth and Falsehood |accessdate=10 September 2013}}</ref> Everything else evaluates to <code>true</code>.
 
== Python, Ruby, and JavaScript ==
In [[Python (programming language)|Python]] from version 2.3 forward, there is a <code>bool</code> type which is a [[subclass (computer science)|subclass]] of <code>int</code>, the standard integer type.<ref>{{cite web | last = Van Rossum | first = Guido | authorlink = Guido van Rossum | title =  PEP 285 -- Adding a bool type | date = 3 April 2002 | url = http://www.python.org/dev/peps/pep-0285/ | accessdate = 15 May 2013}}</ref> It has two possible values: <code>True</code> and <code>False</code>, which are "special versions" of 1 and 0 respectively and behave as such in arithmetic contexts. In addition, a numeric value of zero (integer or fractional), the null value (<code>None</code>), the empty [[String (computer science)|string]], and empty containers (i.e. [[list (computing)|lists]], [[set (computing)|sets]], etc.) are considered Boolean false; all other values are considered Boolean true by default.<ref>{{cite web |url= http://docs.python.org/3.3/reference/expressions.html |title= Expressions |website= Python v3.3.2 documentation | accessdate = 15 May 2013}}</ref> Classes can define how their instances are treated in a Boolean context through the special method <code>__nonzero__</code> (Python 2) or <code>__bool__</code> (Python 3). For containers, <code>__len__</code> (the special method for determining the length of containers) is used if the explicit Boolean conversion method is not defined.
 
In [[Ruby (programming language)|Ruby]], on the other hand, only <code>nil</code> (Ruby's null value) and a special <code>false</code> object are "false", everything else (including the integer 0 and empty arrays) is "true".
 
In [[JavaScript]], the empty string (<code>""</code>), <code>null</code>, <code>undefined</code>, <code>[[NaN]]</code>, +0, [[−0]] and <code>false</code><ref>{{cite web
|url=http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf |title=ECMAScript Language Specification |page=43}}</ref>
are sometimes called "falsy", and their [[complement (set theory)|complement]], "truthy", to distinguish between strictly [[type-checked]] and [[type coercion|coerced]] Booleans.<ref>{{cite web |url=http://javascript.crockford.com/style2.html |title=The Elements of JavaScript Style |publisher=Douglas Crockford |accessdate=5 March 2011}}</ref> Languages such as [[PHP]] also use this approach.
 
== SQL ==
The [[SQL:1999]] standard introduced a BOOLEAN data type as an optional feature (T031). When restricted by a <code>NOT NULL</code> constraint, a SQL BOOLEAN behaves like Booleans in other languages. In SQL however, the BOOLEAN type is [[nullable type|nullable]] by default like all other SQL data types, meaning it can have the special [[Null (SQL)|null]] value as well. Although the SQL standard defines three [[Literal (computer programming)|literals]] for the BOOLEAN type&mdash;TRUE, FALSE and UNKNOWN&mdash;, it also says that the NULL BOOLEAN and UNKNOWN "may be used interchangeably to mean exactly the same thing".<ref name="Date2011">{{cite book|author=C. Date|title=SQL and Relational Theory: How to Write Accurate SQL Code|url=http://books.google.com/books?id=Ew06OZtjuJEC&pg=PA83|year=2011|publisher=O'Reilly Media, Inc.|isbn=978-1-4493-1640-2|page=83}}</ref><ref>ISO/IEC 9075-2:2011 §4.5</ref> This has caused some controversy because the identification subjects UNKNOWN to the equality comparison rules for NULL. More precisely UNKNOWN = UNKNOWN is not TRUE but UNKNOWN/NULL.<ref name="Prigmore2007">{{cite book|author=Martyn Prigmore|title=Introduction to Databases With Web Applications|url=http://books.google.com/books?id=PKggKqIZnN0C&pg=PA197|year=2007|publisher=Pearson Education Canada|isbn=978-0-321-26359-9|page=197}}</ref> As of 2012 few major SQL systems implement the T031 feature.<ref>Troels Arvin, [http://troels.arvin.dk/db/rdbms/#data_types-boolean Survey of BOOLEAN data type implementation]</ref> [[PostgreSQL]] is a notable exception, although it does not implement the UNKNOWN literal; NULL can be used instead.<ref>http://www.postgresql.org/docs/current/static/datatype-boolean.html</ref> (PostgreSQL does implement the IS UNKNOWN operator, which is part of an orthogonal feature, F571.) In other SQL implementations various ad hoc solutions are used, like [[bit]], [[byte]], and [[character (computing)|character]] to simulate Boolean values.
 
==See also==
*[[true and false (Unix)|true and false]] commands for [[shell scripting]]
*[[Shannon's expansion]]
*[[stdbool.h]] — C99 definitions for boolean
 
==References==
{{Reflist|2}}
 
{{data types}}
 
{{DEFAULTSORT:Boolean Data Type}}
[[Category:Boolean algebra]]
[[Category:Data types]]
[[Category:Primitive types]]
[[Category:Articles with example ALGOL 68 code]]

Revision as of 12:32, 28 January 2014

In computer science, the Boolean or logical data type is a data type, having two values (usually denoted true and false), intended to represent the truth values of logic and Boolean algebra. It is named after George Boole, who first defined an algebraic system of logic in the mid 19th century. The Boolean data type is the primary result of conditional statements, which allow different actions and change control flow depending on whether a programmer-specified boolean condition evaluates to true or false.

Generalities

In programming languages that have a built-in Boolean data type, such as Pascal and Java, the comparison operators such as > and are usually defined to return a Boolean value. Conditional and iterative commands may be defined to test Boolean-valued expressions.

Languages without an explicit Boolean data type, like C90 and Lisp, may still represent truth values by some other data type. Lisp uses an empty list for false, and any other value for true. C uses an integer type, where relational expressions like i > j and logical expressions connected by && and || are defined to have value 1 if true and 0 if false, whereas the test parts of if, while, for, etc., treat any non-zero value as true.[1][2] Indeed, a Boolean variable may be regarded (and be implemented) as a numerical variable with a single binary digit (bit), which can store only two values. It is worth noting that the implementation of booleans in computers are most likely represented as a full word, rather than a bit; this is usually due to the ways computers transfer blocks of information.

Most programming languages, even those that do not have an explicit Boolean type, have support for Boolean algebraic operations such as conjunction (AND, &, *), disjunction (OR, |, +), equivalence (EQV, =, ==), exclusive or/non-equivalence (XOR, NEQV, ^, !=), and negation (NOT, ~, !).

In some languages, like Ruby, Smalltalk, and Alice the "true" and "false" values belong to separate classes—e.g. True and False, resp.—so there is no single Boolean "type."

In SQL, which uses a three-valued logic for explicit comparisons because of its special treatment of Nulls, the Boolean data type (introduced in SQL:1999) is also defined to include more than two truth values, so that SQL "Booleans" can store all logical values resulting from the evaluation of predicates in SQL. A column of Boolean type can also be restricted to just TRUE and FALSE though.

In the lambda calculus model of computing, Boolean values can be represented as Church booleans.

ALGOL, Java, and C#

One of the earliest languages to provide an explicit Boolean data type was ALGOL 60 (1960) with values true and false and logical operators denoted by symbols '' (and), '' (or), '' (implies), '' (equivalence), and '¬' (not). Due to input device limitations of the time, however, most compilers used alternative representations for the latter, such as AND or 'AND'.

This approach ("Boolean is a separate built-in primitive data type") was adopted by many later languages, such as ALGOL 68 (1970),[3] Java, and C#.

Fortran

The first version of FORTRAN (1957) and its successor FORTRAN II (1958) did not have logical values or operations; even the conditional IF statement took an arithmetic expression and branched to one of three locations according to its sign; see arithmetic IF. FORTRAN IV (1962), however, followed the ALGOL 60 example by providing a Boolean data type (LOGICAL), truth literals (.TRUE. and .FALSE.), Boolean-valued numeric comparison operators (.EQ., .GT., etc.), and logical operators (.NOT., .AND., .OR.). In FORMAT statements, a specific control character ('L') was provided for the parsing or formatting of logical values.[4]

Lisp and Scheme

The Lisp language (1958) never had a built-in Boolean data type. Instead, conditional constructs like cond assume that the logical value "false" is represented by the empty list (), which is defined to be the same as the special atom nil or NIL; whereas any other s-expression is interpreted as "true". For convenience, most modern dialects of Lisp predefine the atom t to have value t, so that one can use t as a mnemonic notation for "true".

This approach ("any value can be used as a Boolean value") was retained in most Lisp dialects (Common Lisp, Scheme, Emacs Lisp), and similar models were adopted by many scripting languages, even ones that do have a distinct Boolean type or Boolean values; although which values are interpreted as "false" and which are "true" vary from language to language. In Scheme, for example, the "false" value is an atom distinct from the empty list, so the latter is interpreted as "true".

Pascal, Ada, and Haskell

The Pascal language (1978) introduced the concept of programmer-defined enumerated types. A built-in Boolean data type was then provided as a predefined enumerated type with values FALSE and TRUE. By definition, all comparisons, logical operations, and conditional statements applied to and/or yielded Boolean values. Otherwise, the Boolean type had all the facilities which were available for enumerated types in general — such as ordering and use as indices. On the other hand, the conversion between Booleans and integers (or any other types) still required explicit tests or function calls, as in ALGOL 60. This approach ("Boolean is an enumerated type") was adopted by most later languages which had enumerated types, such as Modula, Ada and Haskell.

C, C++, Objective-C, Awk, Perl

The initial implementations of the C language (1972) provided no Boolean type, and to this day Boolean values are commonly represented by integers (ints) in C programs. The comparison operators ('>', '==', etc.) are defined to return a signed integer (int) result, either zero (for false) or 1 (for true). Logical operators ('&&', '||', '!', etc.) and condition-testing statements ('if', 'while') assume that zero is false and all other values are true. One problem with this approach is that the tests if(t==TRUE){...} and if(t) are not equivalent.

After enumerated types (enums) were added to the ANSI version of C (1989), many C programmers got used to defining their own Boolean types as such, for readability reasons. However, enumerated types are equivalent to integers according to the language standards; so the effective identity between Booleans and integers is still valid for C programs.

Standard C (since C99) and several dialects of C such as Objective-C provide definitions of a Boolean type as an integer type and macros for "false" and "true" as 0 and 1, respectively. Thus logical values can be stored in integer variables, and used anywhere integers would be valid, including in indexing, arithmetic, parsing, and formatting. This approach ("Boolean values are just integers") has been retained in all later versions of C.

C++ has a separate Boolean data type ('bool'), but with automatic conversions from scalar and pointer values that are very similar to those of C. This approach was adopted also by many later languages, especially by some scripting ones such as AWK.

Objective-C also has a separate Boolean data type ('BOOL'), with possible values being YES or NO, equivalents of true and false respectively.[5]

Perl has many values of false: the number zero, the strings "0" and "", the empty list "()", and the special value undef.[6] Everything else evaluates to true.

Python, Ruby, and JavaScript

In Python from version 2.3 forward, there is a bool type which is a subclass of int, the standard integer type.[7] It has two possible values: True and False, which are "special versions" of 1 and 0 respectively and behave as such in arithmetic contexts. In addition, a numeric value of zero (integer or fractional), the null value (None), the empty string, and empty containers (i.e. lists, sets, etc.) are considered Boolean false; all other values are considered Boolean true by default.[8] Classes can define how their instances are treated in a Boolean context through the special method __nonzero__ (Python 2) or __bool__ (Python 3). For containers, __len__ (the special method for determining the length of containers) is used if the explicit Boolean conversion method is not defined.

In Ruby, on the other hand, only nil (Ruby's null value) and a special false object are "false", everything else (including the integer 0 and empty arrays) is "true".

In JavaScript, the empty string (""), null, undefined, NaN, +0, −0 and false[9] are sometimes called "falsy", and their complement, "truthy", to distinguish between strictly type-checked and coerced Booleans.[10] Languages such as PHP also use this approach.

SQL

The SQL:1999 standard introduced a BOOLEAN data type as an optional feature (T031). When restricted by a NOT NULL constraint, a SQL BOOLEAN behaves like Booleans in other languages. In SQL however, the BOOLEAN type is nullable by default like all other SQL data types, meaning it can have the special null value as well. Although the SQL standard defines three literals for the BOOLEAN type—TRUE, FALSE and UNKNOWN—, it also says that the NULL BOOLEAN and UNKNOWN "may be used interchangeably to mean exactly the same thing".[11][12] This has caused some controversy because the identification subjects UNKNOWN to the equality comparison rules for NULL. More precisely UNKNOWN = UNKNOWN is not TRUE but UNKNOWN/NULL.[13] As of 2012 few major SQL systems implement the T031 feature.[14] PostgreSQL is a notable exception, although it does not implement the UNKNOWN literal; NULL can be used instead.[15] (PostgreSQL does implement the IS UNKNOWN operator, which is part of an orthogonal feature, F571.) In other SQL implementations various ad hoc solutions are used, like bit, byte, and character to simulate Boolean values.

See also

References

43 year old Petroleum Engineer Harry from Deep River, usually spends time with hobbies and interests like renting movies, property developers in singapore new condominium and vehicle racing. Constantly enjoys going to destinations like Camino Real de Tierra Adentro.

Template:Data types

  1. 20 year-old Real Estate Agent Rusty from Saint-Paul, has hobbies and interests which includes monopoly, property developers in singapore and poker. Will soon undertake a contiki trip that may include going to the Lower Valley of the Omo.

    My blog: http://www.primaboinca.com/view_profile.php?userid=5889534
  2. 20 year-old Real Estate Agent Rusty from Saint-Paul, has hobbies and interests which includes monopoly, property developers in singapore and poker. Will soon undertake a contiki trip that may include going to the Lower Valley of the Omo.

    My blog: http://www.primaboinca.com/view_profile.php?userid=5889534
  3. Template:Cite web
  4. Digital Equipment Corporation, DECSystem10 FORTRAN IV Programmers Reference Manual. Reprinted in Mathematical Languages Handbook. Online version accessed 2011-11-16.
  5. http://developer.apple.com/library/ios/#documentation/cocoa/conceptual/ProgrammingWithObjectiveC/FoundationTypesandCollections/FoundationTypesandCollections.html
  6. Template:Cite web
  7. Template:Cite web
  8. Template:Cite web
  9. Template:Cite web
  10. Template:Cite web
  11. 20 year-old Real Estate Agent Rusty from Saint-Paul, has hobbies and interests which includes monopoly, property developers in singapore and poker. Will soon undertake a contiki trip that may include going to the Lower Valley of the Omo.

    My blog: http://www.primaboinca.com/view_profile.php?userid=5889534
  12. ISO/IEC 9075-2:2011 §4.5
  13. 20 year-old Real Estate Agent Rusty from Saint-Paul, has hobbies and interests which includes monopoly, property developers in singapore and poker. Will soon undertake a contiki trip that may include going to the Lower Valley of the Omo.

    My blog: http://www.primaboinca.com/view_profile.php?userid=5889534
  14. Troels Arvin, Survey of BOOLEAN data type implementation
  15. http://www.postgresql.org/docs/current/static/datatype-boolean.html