endianness

Converting float values from big endian to little endian

Is it possible to convert floats from big to little endian? I have a value from a PowerPC(big endian)platform that I am send via TCP to a Windows process (little endian). This value is a float, but when I "memcpy" the value into a win32 float type and then call _byteswap_ulongon that value, I always get 0.0000? What am I doing wrong...

Large flags enumerations in C#

Hey everyone, got a quick question that I can't seem to find anything about... I'm working on a project that requires flag enumerations with a large number of flags (up to 40-ish), and I don't really feel like typing in the exact mask for each enumeration value: public enum MyEnumeration : ulong { Flag1 = 1, Flag2 = 2, Flag...

Endianness and C API's: Specifically OpenSSL.

I have an algorithm that uses the following OpenSSL calls: HMAC_update() / HMAC_final() // ripe160 EVP_CipherUpdate() / EVP_CipherFinal() // cbc_blowfish These algorithm take a unsigned char * into the "plain text". My input data is comes from a C++ std::string::c_str() which originate from a protocol buffer object as a encoded UTF-8 ...

What header file is where the boost libray define its own primitive data type?

Recently, I try to use the boost::spirit::qi binary endian parser to parse some binary data depends on the endianness of the Platform. There is a simple example, like following: Using declarations and variables: using boost::spirit::qi::little_word; using boost::spirit::qi::little_dword; using boost::spirit::qi::little_qword; boost:...

Byte order (endian) of int in NSLog?

NSLog function accepts printf format specifiers. My question is about %x specifier. Does this print hex codes as sequence on memory? Or does it have it's own printing sequence style? unsigned int a = 0x000000FF; NSLog(@"%x", a); Results of above code on little or big endian processors are equal or different? And how about NSString's -...

Does this have anything to do with endian-ness?

For this code: #include<stdio.h> void hello() { printf("hello\n"); } void bye() { printf("bye\n"); } int main() { printf("%p\n", hello); printf("%p\n", bye); return 0; } output on my machine: 0x80483f4 0x8048408 [second address is bigger in value] on Codepad 0x8048541 0x8048511 [second address is smaller in v...

How to test your code on a machine with big-endian architecture?

Both ideone.com and codepad.org have Little-Endian architechtures. I want to test my code on some machine with Big-Endian architechture (for example - Solaris - which I don't have). Is there some easy way that you know about? ...

Boost Binary Endian parser not working?

I am studying how to use boost spirit Qi binary endian parser. I write a small test parser program according to here and basics examples, but it doesn't work proper. It gave me the msg:"Error:no match". Here is my code. #include "boost/spirit/include/qi.hpp" #include "boost/spirit/include/phoenix_core.hpp" #include "boo...

Wireshark Plugin: Is There a non-ntoh Version of tvb_get_ntoh64?

I am writing a Wireshark dissector plugin for a protocol that does not hton it's data, and I need to extract a 64-bit data value without doing any endian conversions. Is there a version of tvb_get_ntoh64 included in the Wireshark libraries that does not do the ntoh? ...

how is data stored at bit level according to "Endianness" ?

I read about Endianness and understood squat... so I wrote this main() { int k = 0xA5B9BF9F; BYTE *b = (BYTE*)&k; //value at *b is 9f b++; //value at *b is BF b++; //value at *b is B9 b++; //value at *b is A5 } k was equal to A5 B9 BF 9F and (byte)pointer "walk" o/p was 9F BF b9 A5 so I get it byte...

IAR Embedded Workbench - setting endian-ness of variable

I'm using IAR Embedded Workbench for ARM (ARM7TDMI-S) and the majority of my work is done using little-endian format. However, I saw in the manual that I can do something like : __big_endian int i, j; to declare those two variables as big endian (while the rest of the app as little endian). This seems like a fantastic feature, but w...

Floating point Endianness?

Hi I'm writing a client and a server for a realtime offshore simulator, and, as I have to send a lot of data through a socket, I'm using binary data to maximize the ammount of data I can send. I already know about integers endianness, and how to use htonl and ntohl to circumvent endianness issues, but my application, as almost all simul...

Casting a byte array to a struct pointer depends on endianness or memory alignment?

Suppose this code: unsigned char list[3] = { 1, 2, 3 }; struct _struct{ unsigned char a; unsigned char b; unsigned char c; } *s; s = ( _struct * ) list; Can I assume that always s->a == 1, s->b == 2, s->c == 3 ? Or it will depend on the system's endianness or memory alignment? ...

When processor endian awareness is required?

Hi, I am in Mac. With Cocoa, I know with normal files we can directly read or write without worrying about the endianness. When processor endian awareness is required? Regards, Dhana. ...

Is there any "standard" htonl-like function for 64 bits integers in C++ ?

Hi, I'm working on an implementation of the memcache protocol which, at some points, uses 64 bits integer values. These values must be stored in "network byte order". I wish there was some uint64_t htonll(uint64_t value) function to do the change, but unfortunately, if it exist, I couldn't find it. So I have 1 or 2 questions: Is the...

how to convert big-endian numbers to native numbers delphi

I want to know how to convert big-endian numbers to native numbers in Delphi. I am porting some C++ code in that I came across: unsigned long blockLength = *blockLengthPtr++ << 24; blockLength |= *blockLengthPtr++ << 16; blockLength |= *blockLengthPtr++ << 8; blockLength |= *blockLengthPtr; unsigned long dataLength = *dataLengthPtr++...

Details about Endian-ness and .Net?

I have a few questions about endian-ness that are related enough that I warrant putting them in as one question: 1) Is endian-ness decided by .Net or by the hardware? 2) If it's decided by the hardware, how can I figure out what endian the hardware is in C#? 3) Does endian-ness affect binary interactions such as ORs, ANDs, XORs, or sh...

Encode integer as variable-length big-endian byte-array

I need to write an integer to a byte array such that leading zeros are omitted and the bytes are written in big endian order. Example: int original = 0x00123456; byte[] encoded = Encode(original); // == new byte[] { 0x12, 0x34, 0x56 }; int decoded = Decode(encoded); // == 0x123456 My Decode method: private static int ...

String base64 decoded un-gziped from little-endian 4-byte int to java int

Hi, I'm trying to implement TMX files in Android and I was hoping someone could help. Based on the TMX guide, in order to get the GID's I have to first base64 decode the string, then gunzip the resulting data if the compression attribute is set to "gzip" as in the above example. Finally, you can read 4 bytes at a time for each GID f...

Why both utf-16le and utf-16be exists? endianness efficiency - C

I was wondering why both utf-16le and utf-16be exists? Is it considered to be "inefficient" for a big-endian environment to process a little-endian data? Currently, this is what I use while storing 2 bytes var locally: unsigned char octets[2]; short int shotint = 12345; /* (assuming short int = 2 bytes) */ octets[0] = (shortint) ...