endianness Questions

5

Solved

I'm trying to write a byteswap routine for a C++ program running on Win XP. I'm compiling with Visual Studio 2008. This is what I've come up with: int byteswap(int v) // This is good { return _by...
Bulge asked 9/2, 2011 at 18:51

17

The man pages for htonl() seem to suggest that you can only use it for up to 32 bit values. (In reality, ntohl() is defined for unsigned long, which on my platform is 32 bits. I suppose if the unsi...
Orson asked 1/5, 2009 at 1:53

2

Solved

I need to do a lot of bit-wise operations on GPUs, but cannot find any information regarding whether NVIDIA GPU hardware is big or little-endian.
Jaan asked 12/3, 2013 at 8:40

11

Solved

I've seen a few questions and answers regarding to the endianness of structs, but they were about detecting the endianness of a system, or converting data between the two different endianness. Wha...
Brickey asked 18/7, 2011 at 11:21

6

Solved

I'm trying to build a 32-bit float out of its 4 composite bytes. Is there a better (or more portable) way to do this than with the following method? #include <iostream> typedef unsigned cha...

2

Solved

I'm working with integers and SSE and have become very confused about how endianness affects moving data in and out of registers. My initial, wrong, understanding Initially my understanding was as ...
Disremember asked 4/6, 2014 at 18:39

1

I have a bunch of binary data (the contents of a video game save-file, as it happens) where a part of the data contains both little-endian and big-endian integer values. Naively, without reading mu...
Pd asked 17/2, 2018 at 19:51

3

Solved

I'm trying to reverse the bytes for a 64 bit address pointer for an assignment and have this code: char swapPtr(char x){ x = (x & 0x00000000FFFFFFFF) << 32 | (x & 0xFFFFFFFF00000000)...
Bryant asked 2/2, 2014 at 6:13

1

Solved

Since C++20 we can have: constexpr bool is_little_endian = std::endian::native == std::endian::little; I would like to have code that does this if it is available, otherwise does runtime detecti...
Tropophilous asked 9/4, 2020 at 6:7

1

I wrote a simple program in c which calls a function called while_loop with arguments 4,3,2. The function is just basically a while loop, I don't think it's really that relevant to my question sinc...
Anyone asked 28/3, 2020 at 18:26

4

What is the simplest way to work with big-endian values in RISC-V at the assembly language level? That is, how to load a big-endian value from memory into a register, work with the register value i...
Longitudinal asked 30/8, 2018 at 14:33

5

Solved

I have the following code for network protocol implementation. As the protocol is big endian, I wanted to use the Bit_Order attribute and High_Order_First value but it seems I made a mistake. With...
Attract asked 18/6, 2019 at 19:55

5

Solved

Is there an easy way to read these integers in? I'd prefer a built in method, but I assume it is possible to do with some bit operations. Cheers edit I thought of another way to do it that is diff...
Aponte asked 24/9, 2010 at 1:45

3

Solved

I use the following code to read BigEndian information using BinaryReader but I'm not sure if it is the efficient way of doing it. Is there any better solution? Here is my code: // some code to i...
Hudnall asked 18/1, 2013 at 14:43

12

Solved

Is there a safe, portable way to determine (during compile time) the endianness of the platform that my program is being compiled on? I'm writing in C. [EDIT] Thanks for the answers, I decid...
Depress asked 21/11, 2010 at 19:55

1

Solved

It appears that ARM processors can be configured as big-endian or little-endian. However, according to the interwebs, ARM processors are "almost always" configured as little-endian. Is it guarantee...
Spikenard asked 29/10, 2019 at 19:55

7

Solved

I read that the order of bit fields within a struct is platform specific. What about if I use different compiler-specific packing options, will this guarantee data is stored in the proper order as ...
Serpasil asked 29/9, 2009 at 1:7

3

Solved

Is it possible to write a macro in C which takes an uint32_t and converts it to big endian representation no matter if the target system is little or big endian such that the macro can be evaluated...
Cartilage asked 17/9, 2019 at 13:52

2

Solved

I want to use the htonl function in my ruby c extension, but don't want to use any of the other internet stuff that comes with it. What would be the most minimalistic file to #include that is still...
Picture asked 4/7, 2010 at 3:36

4

Solved

I need to read a binary file consisting of 4 byte integers (little endian) into a 2D array for my Android application. My current solution is the following: DataInputStream inp = null; try { inp ...
Mufinella asked 22/2, 2011 at 12:29

3

Solved

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 ...
Casuist asked 15/5, 2010 at 5:53

0

I'm trying to compile rustc for the e5500 FreeScale process CPU, which is 32-bit and little-endian. I'm following the instructions from rust-cross. I've tried two avenues: powerpc-unknown-linux-...
Farnesol asked 3/7, 2019 at 19:26

2

Is there a relation between endianness of a processor and the direction of stack growth? For example, x86 architecture is little endian and the stack grows downwards (i.e. it starts at highest add...
Campy asked 27/8, 2013 at 15:43

5

Solved

I am writing server and client based on WebSocket protocol. Server is made using Python and Twisted. Right now I can send binary data from server to client and back, only problem is that, accordi...
Ruscio asked 31/1, 2013 at 21:25

2

Solved

Say I am reading and writing uint32_t values to and from a stream. If I read/write one byte at a time to/from a stream and shift each byte like the below examples, will the results be consistent re...
Solis asked 30/5, 2019 at 20:27

© 2022 - 2024 — McMap. All rights reserved.