|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#2
|
|||||
|
|||||
|
Re: Interger Representation - Huh?!
Quote:
2.7 ISO DIVERGENCES 2.7.1 Integer Promotions ISO mandates that all arithmetic be performed at int precision or greater. By default, MPLAB C18 will perform arithmetic at the size of the largest operand, even if both operands are smaller than an int. The ISO mandated behavior can be instated via the -Oi command-line option. For example: Code:
unsigned char a, b; unsigned i; a = b = 0x80; i = a + b; /* ISO requires that i == 0x100, but in C18 i == 0 */ For example: Code:
#define A 0x10 /* A will be considered a char unless -Oi specified */ #define B 0x10 /* B will be considered a char unless -Oi specified */ #define C (A) * (B) unsigned i; i = C; /* ISO requires that i == 0x100, but in C18 i == 0 */ ===== It is confusing. I think you could cast the literal as an (int): Code:
foo = (int)127 + (int)127; Code:
foo = 127L + 127L; Last edited by Joe Johnson : 21-02-2004 at 21:58. |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|