Abl-electronic PIC Microcontrollers PIC16 Manuale Utente Pagina 92

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 312
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 91
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
// = 2. + 3.1 = 5.1
5/4*3.
// = (5/4)*3. = 1*3. = 1.*3. = 3.0
3.*5/4
// = (3.*5)/4 = (3.*5.)/4 = 15./4 = 15./4. = 3.75
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 (
type
*) will convert a pointer to type “pointer to
type
”.
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,
then coerce b to double automatically,
resulting in double type value: */
(double) a + b;
// equivalent to ((double) a) + b;
mikroC
- C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...
84
MikroElektronika:
Development
tools
-
Books
-
Compilers
page
Vedere la pagina 91
1 2 ... 87 88 89 90 91 92 93 94 95 96 97 ... 311 312

Commenti su questo manuale

Nessun commento