You are on page 1of 4
5.4.2 Integer Data Types The MPLAB XCB compiler supports integer data types with 1, 2,3 and 4 byte sizes as well as a single bit type. Table 5-1 shows the data types and their corresponding size and arithmetic type. The default type for each type is underlined TABLE $1: _ INTEGER DATA TYPES Type ‘Size (bits) ‘Arithmetic Type bie 1 [Unsigned integer signed char @ [Signed integer fensigned char @ [Unsigned integer Signed short 1 [Signed integer fansigned shox 18 [Unsigned integer signed iat 16 [Signed integer fansigned int 16 [Unsigned integer gigned shoes leng 2 [Signed integer fensigned sheet long 2 [Unsigned integer igned long Ey [Signed integer jansigned Long a [Unsigned integer Signed Jong long Ea [Signed integer fansigned long long 3 [Unsigned integer The bic and shore Long types are non-standard types available in this implementa- tion. The Long long types are C99 Standard types. All integer values are represented in litte endian format with the Least Signifieant bit (LSb) atthe lower address. lfne signedness is specified in the type, then the type will be signed except forthe chaz types which are always unsigned. The bit type is always unsigned and the concept of a signed bit is meaningless. ‘Signed values are stored as a two's complement integer value. ‘The range of values eapable of being held by these types is summarized in Table 5-2 The symbols in this table are preprocessor macros which are available after including «Limits. ho in your source code. ‘As the size of data types are not fully specified by the ANSI Standard, these macros allow for more portable code which can check the limits of the range of values held by the type on this implementation. ‘The macros associated with the short Long type are non-standard maeros available in this implementation; those associated with the Leng leng types are defined by the C99 Standard. TABLE 5-2: RANGES OF INTEGER TYPE VALUES Symbol Meaning Value CHAR _BIT Bits per char = CHAR_MAX Max value ofa char 1a CHAR_MIN Min. value of a chaz 128 ‘SCHAR 2a Max value ofa signed char 17 ‘SCHAR_MIW Min value ofa signed char 128 UCHAR MAX Maxvalueefanunsigned char [266 SHRT_MAX Max value ofa shozt aa7er SHRT_MIN Min. vahie of a shore 2768 USHRT 2a Maxvaluecfanunsigned shore [05635 TNT MAX Max value ofan int a7eT INT_MIN Min. value of a int 2768 UENT_MAX Max value ofan unsigned inv Ge SHRTLONG AK Max value ofa short long 2988007 SHRTLONG MIN Min value ofa short long -asaae08 USHRTLONG MAX [Max valeofanunsigned shore [10777216 Leng LONG_MAK Max value ofe long [ziarsecea7 LONG_MIW Min. value of a Long 21474838 ULONG MAX Maxvaluecfanunsigned leng [4204067205 LEONG 3X Max value ofa long ong [ararsssea7 LLONG_MIW Min. value ofa long long 2147483686 UELONG_MAK Mex valieofansasignes Teng [4zes997z95 ong Macros are also available in which define values associated with {fixed-width types. When specifying a signed orunsigned chert int, sheet long int, leng int oricag long int type, the keyword inc can be omitted. Thus a variable declared as shozt will containa signed short int anda variable declared as unsigned short willcontain an unsigned short int. Itis a common misconception that the C chaz types are intended purely for ASCII char- acter manipulation. However, the C language makes no guarantee that the default character representation is even ASCII. (This implementation does use ASCII as the character representation.) The chaz types are the smallest of the multi-bit integer sizes, and behave in all respects like integers. The reason for the name ‘char*is historical and does not mean that chaz can only be used to represent characters. Itis possible to freely mix char values with values of other types in C expressions. With the MPLAB XCB C Compiler, the shar types are used for a number of purposes — a8 8-bit integers, as storage for ASCII characters, and for access to I/O locations. 5.4.3 Floating-Point Data Types ‘The MPLAB XC& compiler supports 24- and 32-bit floating-point types. Floating point is implemented using either a IEEE 754 32-bit format, or a modified (truncated) 24-bit form of this. Table 5-3 shows the data types and their corresponding size and arithmetic type. TABLE 5-3: FLOATING-POINT DATA TYPES Type ‘Size (bits) Arithmetic Type ‘Float [24 or 32 Real double [Ba or 82 Real ong double [same as double Real Forboth float and double values, the 24-bit format is the default. The options ~-FLORT=24 and --DOUSLE=24 can also be used to specify this explicitly. The 32-bit, format is used for double values if the --DOUBLE=32 option is used and for Flcas. values if --FLOAT=32 is used Variables can be declared using the float and double keywords, respectively, to hold values of these types. Floating-point types are always signed and the unsigned keyword ie illegal when specifying a floating-point type. Types declared as Leng. double will use the same format as types declared as doubie. All floating-point val- es are represented in little endian format with the LSb at the lower address. “This format is described in Table S-4, where: + Sign isthe sign bit which incieates ifthe number is posite er negative + The exponents &bits which is stored as excess 127 (i.e., an exponent of Ois stored as 127) + Mantis is the mantissa, which is to the right of the radix point. There is an implied bit to the left of the radix point which is always 1 except for a zero value, where the implied bit is zero. A zero value is indicated by a zero exponent. “The value of tis numiver is (1)69" x 22908127) 4, mantissa TABLE 5-4; FLOATING-POINT FORMATS Format Sign | _ Biased exponent Mantissa IEEE 764 32-58 x EO 2000 75, 200 08100 DO IEE modified EEE TES | x "ee 05 7 RE 24-bit TABLE 5-6: RANGES OF FLOATING-POINT TYPE VALUES Symbol Meaning 24-bit Value | 32-bit Value EER_RADIX [Fladix of exponent representation |> rz EEX_noumas [Rounding mode for addition a HEK_MIN_EXP Min. such that FLT_RADIX™ is |-125 ja normalized fost value XEX_MIN_10_2 [Minn such that 107s -a7 a xP jnormalized float value XXX_Max EXP [Max asuch that FLT_RADIX™? [128 128 is @ normalized fost value XE_MAX_10_= [Max such that 107is a 38 Ey =P —_| normalized float value XEX_MANT_DIG [Number of FLT_RADIX mantissa [16 2 digits XEE_EPSILON |The smallest number which sostree0s [119208607 added to 1.0 does nat yield 1.0

You might also like