Symbian3/SDK/Source/GUID-189FBB0E-0A47-5CCC-9209-DC69E76DE6B3.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Tue, 20 Jul 2010 12:00:49 +0100
changeset 13 48780e181b38
parent 0 89d6a7a84779
permissions -rw-r--r--
Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="GUID-189FBB0E-0A47-5CCC-9209-DC69E76DE6B3" xml:lang="en"><title>Boolean</title><shortdesc>This document describes the Boolean data types.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<p><xref href="GUID-4B942C06-1BAC-3A21-B3B1-89FB5C51ADA0.dita"><apiname>TBool</apiname></xref> represents a Boolean whose value may be <codeph>ETrue</codeph> or <codeph>EFalse</codeph>.
It is implemented as a natural machine-word integer.</p>
<p>The C language defines logical expressions to <i>produce</i> 0 for false,
1 for true, and to <i>interpret</i> 0 as false, non-zero as true. This confusion
cannot be altogether avoided with <codeph>TBool</codeph>. It is possible,
but strongly deprecated, to assign numeric values to a <xref href="GUID-4B942C06-1BAC-3A21-B3B1-89FB5C51ADA0.dita"><apiname>TBool</apiname></xref>.</p>
<p>In general, a <xref href="GUID-4B942C06-1BAC-3A21-B3B1-89FB5C51ADA0.dita"><apiname>TBool</apiname></xref> should be tested using</p>
<codeblock id="GUID-BF6AF640-D03A-5335-B67B-3852C2808833" xml:space="preserve">if (x) ...</codeblock>
<p>or</p>
<codeblock id="GUID-D00FBCFD-57C2-5D1E-999A-0567AFBAA258" xml:space="preserve">if (!x) ...</codeblock>
<p>rather than</p>
<codeblock id="GUID-41D4B777-217D-5BA5-B44A-59C2419FB2D6" xml:space="preserve">if (x==ETrue) ...</codeblock>
<p>or</p>
<codeblock id="GUID-72F416BC-213F-5731-B26A-8ECE2916935B" xml:space="preserve">if (x==EFalse) ...</codeblock>
<p>The <xref href="GUID-4B942C06-1BAC-3A21-B3B1-89FB5C51ADA0.dita"><apiname>TBool</apiname></xref> uses a whole machine word. When a class has
a number of flags, they should be encoded in a flags byte, and suitable getter/setter
functions, taking <xref href="GUID-4B942C06-1BAC-3A21-B3B1-89FB5C51ADA0.dita"><apiname>TBool</apiname></xref> s, should be coded to access that
flags byte.</p>
</conbody></concept>