473,809 Members | 2,718 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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%c gl%ssic%ccom%c" , "ma", 58, 'g', 64, "ba", 46, 10);}

Jul 23 '05 #1
4 3477
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
14778
by: hantheman | last post by:
Is this a portable implementation? #if defined(BIG_ENDIAN) && !defined(LITTLE_ENDIAN) #define htons(A) (A) #define htonl(A) (A) #define ntohs(A) (A) #define ntohl(A) (A) #elif defined(LITTLE_ENDIAN) && !defined(BIG_ENDIAN)
4
1964
by: pellepluttrick | last post by:
Hi, I thought I understood this stuff - but... This little program (taken from W. Richard Stevens Unix Network Programming Volume 1) determines a machine's endianess: #include <iostream> using namespace std; int main()
5
5511
by: SpOiLeR | last post by:
Hi. q1: Is std::bitset<N> part of standard or it's compiler extension? q2: Is std::bitset::to_string() part of standard? q3: My documentation say this about std::bitset::to_string(): "...each character is 1 if the corresponding bit is set, and 0 if it is not. In general, character position i corresponds to bit position N - 1 -
8
4090
by: | last post by:
Well! Maybe I wrote this word incorrect but its not included im my e-dictionary! I have a structure with many int, short etc I execute this function: fread(&my_struct, sizeof(struct), 1, filepointer); The problem is this: In different endianess platforms from same file will be loaded different data in the class.
12
1651
by: Oliver Knoll | last post by:
Ok, I've searched this group for Big/Little endian issues, don't kill me, I know endianess issues have been discussed a 1000 times. But my question is a bit different: I've seen the follwing function several times, it converts data stored in Big Endian (BE) format into host native format (LE on LE machines, BE on BE machines):
1
3159
by: mathieu | last post by:
Hello, I am working on a project where I need to serialize my objects to a stream in a mixed ASCII/binary way. Using the c++ iostream was extremely straighforward and I quickly made progress. Unfortunately I need to handle endianess (reading big endian binary file on little endian architecture and vice versa). In order to do that I copy paste a hierachy-like structure for my own IOStream. Basically I have (*) All I need to do then is to...
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9602
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10639
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7661
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5688
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.