endianness

What is a good Windows hex editor / viewer?

I am in need of a hex editor / viewer (viewer is more important than editing, but a plus if it can edit) for Windows. See KHexedit Requirements: Free is best View data at cursor as: byte, short, int, long, float, double (signed/unsiged where applicable) Configure the endiance for multi-byte decoding "Nice to have" features: Strin...

Types of endianness

What is the difference between the following types of endianness? byte (8b) invariant big and little endianness half-word (16b) invariant big and little endianness word (32b) invariant big and little endianness double-word (64b) invariant big and little endianness Are there other types/variations? ...

Best approach to write/read binary data in Little or Big Endian with C#?

Ok, if i've got a binary file encoded either in little endian or big endian under .NET, what is the best way to read / write to it? In the .NET framework i've only managed to found BinaryWritters / BinaryReaders which use little endian as default, so my approach was implement my own BinaryReader / BinaryWritter for reading / writting da...

endian-ness of new macs - are all pc platforms the same now?

Does the change of macs over to intel chips mean we're done with the bit twiddling on numbers in binary resources for cross platform data distributions? Is that the last of this problem or are there some other platforms I'm not aware of? ...

How do I convert between big-endian and little-endian values in C++?

How do I convert between big-endian and little-endian values in C++? EDIT: For clarity, I have to translate binary data (double-precision floating point values and 32-bit and 64-bit integers) from one CPU architecture to another. This doesn't involve networking, so ntoh() and similar functions won't work here. EDIT #2: The answer I ac...

How to convert a number to a bytearray in bit endian order

I am trying to uncompress some data created in VB6 using the zlib API. I have read this is possible with the qUncompress function: http://doc.trolltech.com/4.4/qbytearray.html#qUncompress I have read the data in from QDataStream via readRawBytes into a char array, which I then converted to a QByteArray for decompression. I have the com...

How do I get the integer value of a char in C++?

I want to take the value stored in a 32 bit unsigned int, put it into four chars and then store the integer value of each of these chars in a string. I think the first part goes like this: char a = orig << 8; char b = orig << 8; char c = orig << 8; char d = orig << 8; ...

C# little endian or big endian?

In the documentation of hardware that allows us to control it via UDP/IP, I found the following fragment: In this communication protocol, DWORD is a 4 bytes data, WORD is a 2 bytes data, BYTE is a single byte data. The storage format is little endian, namely 4 bytes (32bits) data is stored as: d7-d0, d15-d8, d23-d16, d31-d24; doubl...

Safely punning char* to double in C

In an Open Source program I wrote, I'm reading binary data (written by another program) from a file and outputting ints, doubles, and other assorted data types. One of the challenges is that it needs to run on 32-bit and 64-bit machines of both endiannesses, which means that I end up having to do quite a bit of low-level bit-twiddling. ...

Is there a way to do a C++ style compile-time assertion to determine machine's endianness?

I have some low level serialization code that is templated, and I need to know the system's endianness at compiletime obviously (because the templates specializes based on the system's endianness). Right now I have a header with some platform defines, but I'd rather have someway to make assertions about endianness with some templated ...

Are Integers in Java little endian or big endian?

I ask because I am sending a byte stream from a C processto Java (through a priority middle ware). On the C side the 32 bit integer has the LSB is the first byte and MSB is the 4th byte. So my question is on the Java side when we read the byte as it was sent from the C process, what is endian on the Java side? A follow up question if t...

How do I write ints out to a text file with the low bits on the right side (Bigendian)

By default the BinaryWriter class writes int values with the low bits on the left (e.g. (int)6 becomes 06 00 00 00 when the resulting file is viewed in a hex editor). I need the low bits on the right (e.g. 00 00 00 06). How do I achieve this? EDIT: Thanks strager for giving me the name for what I was looking for. I've edited the title...

Is endian conversion required for wchar_t data?

In C/C++, if a multi-byte wide character (wchar_t) value is transmitted from a big-endian system to a little-endian system (or vice-versa), will it come out the same value on the other side? Or will the bytes need to be swapped? ...

What tranformations are used by little-endian systems to convert data to network order?

What are the underlying transformations that are necessary to convert data in a little-endian system into network byte order? For 2 byte and 4 byte data there are well-known functions (such as htons, ntohl, etc.) to encapsulate the changes, what happens for strings of 1 byte data (if anything)? Also, Wikipedia implies that little-endian...

endianness theory and concept

This isn't a question specific to any programming language. Say you have some file written on a big-endian machine, and you know this. If two single-byte values were written back-to-back, how would you know? Big-endian reverses the order of 16, 32, and 64 bit values, so how would you know you need to read it as individual bytes? For ...

JavaScript Endian Encoding?

A response on SO got me thinking, does JavaScript guarantee a certain endian encoding across OSs and browsers? Or put another way are bitwise shifts on integers "safe" in JavaScript? ...

Byte order with a large array of characters in C

Hey guys, question from a C/Networking newbie... I'm doing some socket programming in C and trying to wrestle with byte order problems. My request (send) is fine but when I receive data my bytes are all out of order. I start with something like this... char * aResponse= (char *)malloc(512); int total = recv(sock, aResponse, 511, 0); ...

Reading "integer" size bytes from a char* array.

I want to read sizeof(int) bytes from a char* array. a)In what scenario's we need to worry if endian needs to be checked b)how would you read the first 4 bytes considering taking endian consideration or no consideration. EDIT: The sizeof(int) bytes that I have read needs to be compared with the an integer value. What is the best app...

Why do I get the following output when inverting bits in a byte?

Assumption: Converting a byte[] from Little Endian to Big Endian means inverting the order of the bits in each byte of the byte[]. Assuming this is correct, I tried the following to understand this: byte[] data = new byte[] { 1, 2, 3, 4, 5, 15, 24 }; byte[] inverted = ToBig(data); var little = new BitArray(data); var big = ...

Difference between Big Endian and little Endian Byte order

what is the difference between Big Endian byte order and little Endian Byte order. These both are related to Unicode and UTF16 where we use this? ...