avr-chat
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-chat] Simple endianess question


From: Russell Shaw
Subject: Re: [avr-chat] Simple endianess question
Date: Sun, 16 Apr 2006 16:53:36 +1000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20060205 Debian/1.7.12-1.1

Rick Mann wrote:
All my life I've worked on big-endian machines (just about). Certainly all my C career.

In C, do I write hex constants for use on a little-endian machine as big-endian or little?

For example, if I want to mask off the high 4 bits of a 16-bit integer, would I write this:

uint_16 foo;

foo & 0x0FFF;

or would I write:

foo & 0xFF0F;

It is: foo & 0x0FFF

it is the same as foo & 4095. If endian mattered, you'd have to change every
number in your program to compile it on a different endian machine.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]