mikroElektronika PIC Microcontrollers PIC12 User Manual page 92

Mikroc user's manual
Table of Contents

Advertisement

mikroC - C Compiler for Microchip PIC microcontrollers
The result of the expression is the same type as that of the two operands.
Here are several examples of implicit conversion:
2+3.1
5/4*3.
3.*5/4
Pointer Conversions
Pointer types can be converted to other pointer types using the typecasting mecha-
nism:
char *str;
int *ip;
str = (char *)ip;
More generally, the cast (
Explicit Types Conversions (Typecasting)
In most situations, compiler will provide an automatic implicit conversion of types
where needed, without any user interference. Also, you can explicitly convert an
operand to another type using the prefix unary typecast operator:
( type ) object
For example:
char a, b;
/* Following line will coerce a to unsigned int: */
(unsigned int) a;
/* Following line will coerce a to double,
(double) a + b;
page
84
// = 2. + 3.1 = 5.1
// = (5/4)*3. = 1*3. = 1.*3. = 3.0
// = (3.*5)/4 = (3.*5.)/4 = 15./4 = 15./4. = 3.75
type *
then coerce b to double automatically,
resulting in double type value: */
// equivalent to ((double) a) + b;
MikroElektronika: Development tools - Books - Compilers
) will convert a pointer to type "pointer to
mikroC
making it simple...
".
type

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the PIC Microcontrollers PIC12 and is the answer not in the manual?

This manual is also suitable for:

Pic microcontrollers pic16Pic microcontrollers pic18

Table of Contents