mikroC
making it simple...
Arithmetic Conversions
When you use an arithmetic expression, such as
ent arithmetic types, mikroC performs implicit type conversions before the expres-
sion is evaluated. These standard conversions include promotions of "lower" types
to "higher" types in the interests of accuracy and consistency.
Assigning a signed character object (such as a variable) to an integral object
results in automatic sign extension. Objects of type
sign extension; objects of type
when converted to
Converting a longer integral type to a shorter type truncates the higher order bits
and leaves low-order bits unchanged. Converting a shorter integral type to a longer
type either sign-extends or zero-fills the extra bits of the new value, depending on
whether the shorter type is signed or unsigned, respectively.
Note: Conversion of floating point data into integral value (in assignments or via
explicit typecast) produces correct results only if the
the scope of destination integral type.
First, any small integral types are converted according to the following rules:
1.
char
2.
signed char
3.
short
4.
unsigned short
5.
enum
After this, any two values associated with an operator are either
the
long
and
1. If either operand is
2. Otherwise, if either operand is
to
3. Otherwise, if either operand is
4. Otherwise, if either operand is
u
nsigned
5. Otherwise, both operands are
MikroElektronika: Development tools - Books - Compilers
.
int
converts to
int
converts to
converts to
, with the same value, sign-extended
int
converts to unsigned int, with the same value, zero-filled
converts to
, with the same value
int
and
modifiers), or they are float (equivalent with
unsigned
in mikroC).
long double
float
unsigned long
mikroC - C Compiler for Microchip PIC microcontrollers
a+b
signed char
always set the high byte to zero
unsigned char
, with the same value
int
, the other operand is converted to
, the other operand is converted
unsigned long
, the other operand is converted to
long
, the other operand is converted to
unsigned
int
, where
and
are of differ-
a
b
always use
value does not exceed
float
(including
int
double
float
long
page
83
Need help?
Do you have a question about the PIC Microcontrollers PIC12 and is the answer not in the manual?