
www.Usenet.com
| <-- __Chronological__ --> | <-- __Thread__ --> |
#include <stdio.h>
main()
{
int x, y, z; x = 4321;
y = 5678;
printf("Given x = %u, i.e., 0X%04X\n", x, x); printf(" y = %u, i.e., 0X%04X\n", y, y);
return 0; }
I am a total beginner at C programming, and while following an example of using the bitwise complement operator, I got a very different result from that listed in the book.
The example shows the bitwise complement of integer x, (dec value 4321) as being 61214, hex value 0XEF1E. When I compile and run the example, I end up with the dec value 4294962974, hex value 0XFFFFEF1E.
The exercise includes examples of the other bitwise operators, all of which return the same results as the book when I run it.
I should mention that the book seems to lean towards Borland running on Windows -- I am using GCC 3.2.2 on RedHat. Is there something I should be learning about byte ordering or some such? I can't just ignore the problem and move on because I really want to understand whats going on, rather than just learning by rote.
Thanks for any insight.
| <-- __Chronological__ --> | <-- __Thread__ --> |