Symbian3/SDK/Source/GUID-E525E177-1FE5-5845-9BF8-B76D434B838D.dita
changeset 0 89d6a7a84779
equal deleted inserted replaced
-1:000000000000 0:89d6a7a84779
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE concept
       
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
       
    12 <concept id="GUID-E525E177-1FE5-5845-9BF8-B76D434B838D" xml:lang="en"><title>Integral
       
    13 types</title><shortdesc>This document describes the integer data types.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    14 <p><xref href="GUID-7A2A43EC-6125-3BFE-834B-23C37F7B40D5.dita"><apiname>TInt</apiname></xref> is the natural machine word integer and should
       
    15 be used in all general contexts where integer arithmetic is desired.</p>
       
    16 <p><xref href="GUID-49ACAE7B-1FE4-3BA6-8772-F104D3F01E41.dita"><apiname>TInt32</apiname></xref>, <xref href="GUID-6BE0B3FC-2B36-3982-AA51-971F3354925E.dita"><apiname>TInt16</apiname></xref>, and <xref href="GUID-F2669E84-D47E-3C83-A549-D77A883787CC.dita"><apiname>TInt8</apiname></xref> map
       
    17 onto C++ built-in types in most implementations. These types should only be
       
    18 used where the size of the integer is of first importance: sometimes, this
       
    19 is relevant for C++ arrays and struct/class members. Note that C++ passes
       
    20 all function arguments as <xref href="GUID-7A2A43EC-6125-3BFE-834B-23C37F7B40D5.dita"><apiname>TInt</apiname></xref>, so there is nothing to
       
    21 be gained by using narrower types in function interfaces.</p>
       
    22 <p><xref href="GUID-F9432D7B-41C9-3048-AC50-B5BCF8BE11D0.dita"><apiname>TUint</apiname></xref> is an unsigned integer of the natural machine
       
    23 word size. Experience with C and C++ suggests that unsigned integers are not
       
    24 suitable for representing quantities whose valid values should always be positive. <xref href="GUID-7A2A43EC-6125-3BFE-834B-23C37F7B40D5.dita"><apiname>TInt</apiname></xref> should
       
    25 be used in these circumstances instead. The main reasons behind this surprising
       
    26 assertion are, firstly, that surprises occur when C++ performs implicit type
       
    27 conversions for arithmetic and assignment, and, secondly, that C++ does not
       
    28 trap bounds errors, with the result that <xref href="GUID-F9432D7B-41C9-3048-AC50-B5BCF8BE11D0.dita"><apiname>TUint</apiname></xref> s which
       
    29 "accidentally" go negative actually take on very large positive values instead.</p>
       
    30 <p><xref href="GUID-F9432D7B-41C9-3048-AC50-B5BCF8BE11D0.dita"><apiname>TUint</apiname></xref> should be used for flag and handle words, which
       
    31 are manipulated using bitwise and equality-comparison operations rather than
       
    32 arithmetic. <xref href="GUID-F9432D7B-41C9-3048-AC50-B5BCF8BE11D0.dita"><apiname>TUint</apiname></xref> should also be used in exceptional circumstances
       
    33 where the full range of a machine word is required for arithmetic: this use
       
    34 is exceptional and must always be carefully controlled.</p>
       
    35 <p><xref href="GUID-F58A1C0D-1B36-37EA-8012-1C74B2D12CAD.dita"><apiname>TUint32</apiname></xref>, <xref href="GUID-4BB532F8-938E-37C7-9D40-6010EB716E7A.dita"><apiname>TUint16</apiname></xref>, and <xref href="GUID-F894527F-13A6-3E6D-BA7B-187812CDF20E.dita"><apiname>TUint8</apiname></xref> types
       
    36 are available where the specific representation width is important.</p>
       
    37 </conbody></concept>