SW500011 Microchip Technology, SW500011 Datasheet - Page 83

HI-TECH X PRO FOR PIC32

SW500011

Manufacturer Part Number
SW500011
Description
HI-TECH X PRO FOR PIC32
Manufacturer
Microchip Technology
Type
Compilerr
Series
PIC32r
Datasheet

Specifications of SW500011

No. Of User Licenses
1
Supported Families
PIC32
Core Architecture
PIC
Supported Hosts
Windows XP, Vista, Linux, Mac OS X
Software Edition
Professional
Kit Contents
Software And Docs
Tool Type
Compiler
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
PIC32 Series
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
Other names
032
778-1007
778-1007
C Language Features
register will always contain the return address from that function. In non-leaf functions the contents
of the register is preserved on the stack.
3.7 Operators
HI-TECH C PRO for the PIC32 MCU Family supports all the ANSI operators. The exact results of
some of these are implementation defined. The following sections illustrate code produced by the
compiler.
3.7.1 Integral Promotion
When there is more than one operand to an operator, they typically must be of exactly the same type.
The compiler will automatically convert the operands, if necessary, so they have the same type. The
conversion is to a “larger” type so there is no loss of information. Even if the operands have the same
type, in some situations they are converted to a different type before the operation. This conversion
is called integral promotion. HI-TECH C PRO for the PIC32 MCU Family performs these integral
promotions where required. If you are not aware that these changes of type have taken place, the
results of some expressions are not what would normally be expected.
of char, short int or bitfield types to either signed int or unsigned int. If the result of the
conversion can be represented by an signed int, then that is the destination type, otherwise the
conversion is to unsigned int.
The unsigned char result of a - b is 206 (which is not less than 10), but both a and b are con-
verted to signed int via integral promotion before the subtraction takes place. The result of the
subtraction with these data types is -50 (which is less than 10) and hence the body of the if() state-
ment is executed. If the result of the subtraction is to be an unsigned quantity, then apply a cast.
For example:
The comparison is then done using unsigned int, in this case, and the body of the if() would not be
executed.
Integral promotion is the implicit conversion of enumerated types, signed or unsigned varieties
Consider the following example.
unsigned char count, a=0, b=50;
if(a - b < 10)
if((unsigned int)(a - b) < 10)
count++;
count++;
Operators
83

Related parts for SW500011