469,275 Members | 1,459 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,275 developers. It's quick & easy.

ARM endianess?

Hi,

does the ARM processors have different endians than x86 platform? For
ints and/or floating points??? I get a really strange objec when
loading it from a file.

Creating manually works.

--
-Gernot
int main(int argc, char** argv) {printf
("%silto%c%cf%cgl%ssic%ccom%c", "ma", 58, 'g', 64, "ba", 46, 10);}

Jul 23 '05 #1
4 3283
Gernot Frisch wrote:
does the ARM processors have different endians than x86 platform? For
ints and/or floating points??? I get a really strange objec when
loading it from a file.


Most ARMs can be configured (e.g. with a pin) to have either endianness,
so it depends on your platform. The last ARM system I used was
big-endian, i.e. opposite to x86.

But comp.lang.c++ is not a very good place to ask.

--Phil.
Jul 23 '05 #2
Gernot Frisch wrote:
Hi,

does the ARM processors have different endians than x86 platform? For
ints and/or floating points???
And what's your question about standard C++?
I get a really strange objec when loading it from a file.


When reading or writing binary data, it's always good to write your i/o
functions in such a way that endianess doesn't matter.

Jul 23 '05 #3
Rolf Magnus wrote:
Gernot Frisch wrote:
Hi,

does the ARM processors have different endians than x86 platform? For
ints and/or floating points???


And what's your question about standard C++?
I get a really strange objec when loading it from a file.


When reading or writing binary data, it's always good to write your
i/o functions in such a way that endianess doesn't matter.


Sometimes unavoidable, though (eg. interfacing with 3rd party software/data formats).

Out of curiosity, I've just dug up some code I once nicked off some library to detect endianess at runtime. It relies on
IEEE floating-point format details (which probably renders it somewhat non-portable - rather defeating the object of the
exercise ;-)) but may be of interest/use to the OP:

// detect computer architecture
union {double f; uint32 i[2];} convert;
convert.f = 1.0;
if (convert.i[1] == 0x3FF00000) Architecture = LITTLEENDIAN;
else if (convert.i[0] == 0x3FF00000) Architecture = BIGENDIAN;
else Architecture = NONIEEE;}

--
Lionel B

Jul 23 '05 #4
EML
On Mon, 20 Jun 2005 12:20:38 +0100, "Lionel B" <me@privacy.net> wrote:
Out of curiosity, I've just dug up some code I once nicked off some library to detect endianess at runtime. It relies on
IEEE floating-point format details (which probably renders it somewhat non-portable - rather defeating the object of the
exercise ;-)) but may be of interest/use to the OP:

// detect computer architecture
union {double f; uint32 i[2];} convert;
convert.f = 1.0;
if (convert.i[1] == 0x3FF00000) Architecture = LITTLEENDIAN;
else if (convert.i[0] == 0x3FF00000) Architecture = BIGENDIAN;
else Architecture = NONIEEE;}


Dodgy, to put it mildly. I remember working on an early ARM about 10
years ago, which was little-endian, but which put the two halves of an
FP64 in *big*-endian order.

Another issue is that you can't normally rely on a known bit pattern
for an FP number (because of rounding issues), though 1.0 should be
Ok.

Evan
Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.