11.07.2015 Views

PicC 9.50 dsPIC Manual.pdf

PicC 9.50 dsPIC Manual.pdf

PicC 9.50 dsPIC Manual.pdf

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

C Language FeaturesSupported Data Types and Variableskeyword int may be omitted. Thus a variable declared as short will contain a signed short intand a variable declared as unsigned short will contain an unsigned short int.Since the processor’s register are 16-bit wide, it can often be more efficient to use 16-bit integrervariables over 8-bit variables.3.4.5 32-Bit Integer Data Types and VariablesHI-TECH <strong>dsPIC</strong>Csupports two 32-bit integer types. Long is a 32-bit two’s complement signed integertype, representing integral values from -2,147,483,648 to +2,147,483,647 inclusive. Unsignedlong is a 32-bit unsigned integer type, representing integral values from 0 to 4,294,967,295 inclusive.All 32-bit integer values are represented in little endian format with the least significant wordand least significant byte at the lowest address. Long and unsigned long occupy 32 bits as this isthe smallest long integer size allowed by the ANSI standard for C.Variables may be declared using the signed long int and unsigned long int keyword sequences,respectively, to hold values of these types. Where only long int is used in the declaration,the type will be signed long. When specifying this type, the keyword int may be omitted. Thusa variable declared as long will contain a signed long int and a variable declared as unsignedlong will contain an unsigned long int.3.4.6 Floating Point Types and VariablesFloating point is implemented using the IEEE 754 32-bit format.The 32-bit format is used for all float and double values.This format is described in Table 3.4, where:• sign is the sign bit• The exponent is 8-bits which is stored as excess 127 (i.e. an exponent of 0 is stored as 127).• mantissa is the mantissa, which is to the right of the radix point. There is an implied bit to theleft 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 this number is (-1) sign x 2 (exponent−127) x 1.mantissa.Here are some examples of the IEEE 754 32-bit formats:Note that the most significant bit of the mantissa column in Table 3.5 (that is the bit to the leftof the radix point) is the implied bit, which is assumed to be 1 unless the exponent is zero (in whichcase the float is zero).The 32-bit example in Table 3.5 can be calculated manually as follows.The sign bit is zero; the biased exponent is 251, so the exponent is 251-127=124. Take the binarynumber to the right of the decimal point in the mantissa. Convert this to decimal and divide it by 2 2333

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!