Questions tagged [endianness]

Endianness refers to how multi-byte values are stored in memory, sent between devices or stored on disk. "Big-Endian" values are stored with their most-significant byte first, and "Little-Endian" values are stored with their least-significant byte first. Other byte-orders are possible but very uncommon, and cannot be described this way.

Filter by
Sorted by
Tagged with
0 votes
1 answer
34 views

Python Byte-encoding functions do not work as expected

I'm trying to convert a hexadecimal number, like the stack address 0x7ffd6fa90940, into its corresponding Byte representation b'\x40\x09\xa9\x6f\xfd\x7f\x00\x00'. Just like how it is represented in ...
PatrickSteiner's user avatar
0 votes
1 answer
29 views

RFID identifier in big-endian byte order

I've been researching scanning RFID cards with an iphone and hit a point where I have no idea how to move forward with it. Using Apple's CoreNFC library I can scan a card and get it's identifier, the ...
b.stevens.photo's user avatar
-1 votes
0 answers
19 views

Where is the signed byte stored MSB or First byte in the word

When using the Big-Endian assignment to load a string stored in a 64-bit word from memory to a register, the sign bit of the string is stored in (A) The least significant byte (B) The most significant ...
Ameen Osama's user avatar
2 votes
3 answers
83 views

Can I create color struct that works on different endians?

I am trying to create a union to store my color values channel by channel and 4-byte values at the same time. But I am having problems with the order of channels. Different endian machines give ...
Buğrahan Özcan's user avatar
-1 votes
3 answers
120 views

How to read little endian integers in binary files in c++

I have been trying to read a little endian binary file. I am hoping to first find an index of a string in the file from where I can start reading the data. Once I get the index, I will be looking to ...
Kiro's user avatar
  • 5
0 votes
1 answer
67 views

Do I need to account for host machine's endianness when writing to my Buffer class?

I'm writing a Buffer class which simply holds bytes in C++. It's got the usual read and write methods for various types; 16, 32 and 64 bit integers, floats and doubles. I'm using this primarily for in-...
Alex's user avatar
  • 330
2 votes
1 answer
68 views

x86 assembly 64-bit values with 32-bit program

If we multiply two very large 32-bit values the result can end up in registers EDX and EAX, with EDX holding the higher bits. How do we perform operations on these 64-bit values and print them to the ...
Tim's user avatar
  • 145
0 votes
0 answers
42 views

How to find the metadata (byte offset & byte order) of a tiff file

I am doing a meta analysis on some old image data that sits in tiff files. I am not sure how they were generated but I need the byte order and offset to read the file into another program. How can I ...
TheCodeNovice's user avatar
1 vote
1 answer
55 views

STM32G030 / CRC_DR / how to use 32bit writes?

Somehow I do not get 0xD0FA with 0x12345678 and 16bit POLY 0x1021, when I use word access for CRC_DR. exempli gratia: pseudo code: RCC.CRCEN=1; CRC_CR.POLYSIZE=0b01; CRC_POL=0x1021; CRC_INIT=0; CRC_CR....
RRIDDICC's user avatar
  • 119
3 votes
2 answers
109 views

Why is this example not endian-dependent? [closed]

https://cppquiz.org/quiz/question/249 #include <iostream> using namespace std; int main() { int a = '0'; char const &b = a; cout << b; a++; cout << b; } I ...
Decaf Sux's user avatar
  • 337
0 votes
2 answers
83 views

How I can calculate complex function in compile time?

I need to get little endian binary data, so at big endian computers I convert it to little endian by doing this bool IsBigEndian() { int i = 1; return ((*reinterpret_cast<uint8_t*>(&i)) ...
awakair's user avatar
0 votes
3 answers
126 views

How to convert little endian PCM audio samples to big endian

I need to fill a datagram buffer with network byte ordered audio samples per the apt-x RTP layout per RFC 7310 section 5.5: This is how the layout of audio samples sits in my application memory: 24 ...
johnco3's user avatar
  • 2,423
1 vote
0 answers
37 views

Actual examples of JavaScript big-endian systems

Can anyone provide any examples of current-generation web browsers producing big-endian typed arrays by default? This could be either because the underlying system is big-endian or it is bi-endian but ...
Andrew's user avatar
  • 14.3k
0 votes
1 answer
99 views

GCC scalar_storage_order attribute

In C: struct __attribute__((scalar_storage_order("big-endian"))) test_struct{ int a; int b; int c; }; struct test_struct test1 = {1,1,1}; struct test_struct test2[3] = {{1,1,1},{1,1,1},{1,1,...
V8Muscle383's user avatar
1 vote
1 answer
93 views

Calculate Git file blob SHA (handle emojis etc.)

I am pushing files to GitHub using the javascript API. I'd like to avoid using up an API call (toward rate limit) if the file on GitHub is unchanged. Hitting the tree API to get the file's sha doesn't ...
Vince's user avatar
  • 545
0 votes
0 answers
161 views

Given the following memory map, assume that the register $t0 stores value 8 while $s0 contains 0xCAFEFACE. Solve these questions

So for this exercise I can easily solve a), b), e). As for c), I believe the answer would be 0xFFFF9ABC (9 is 1001 in binary with sign extension). d) 0x00000078 (7 is 0111). f) 0x12345678CABCDEF0. g) ...
Nam Truong's user avatar
-1 votes
1 answer
108 views

Compile time endian dependent expressions?

While implementing UDP BitTorrent tracker protocol, I noticed that most common packet parsing step is checking whether first 64 bits are protocol id 0x41727101980, used for requesting a connection, ...
user avatar
0 votes
1 answer
55 views

Why endianness mismatch happens in this code?

Here is simple piece of code from this fiddle: https://jsfiddle.net/vo0aL8h4/2/ It is about a binary endianness issue while making a cross-browser binary data reader/writer code. I was wrong here as ...
Kote Isaev's user avatar
1 vote
0 answers
32 views

boost/endian: arithmetic types cannot be packed (non-POD)?

Boost/endian defines macros which assure its arithmetic types are POD, as explained in the docs. However, no matter how much I try, this MWE #define BOOST_ENDIAN_NO_CTORS #define ...
eudoxos's user avatar
  • 18.6k
0 votes
0 answers
9 views

RTRT module type errir

I have an issue when i running my IBM Rational Test RealTime tool. its tells me that my module differs in machine type or endianness i've checked all the configuration and everything is in little ...
Ptns's user avatar
  • 11
1 vote
1 answer
55 views

When I write moof box from mp4, the ASCII code is reversed

I am trying to extract the 'moof' box from movie box in isobmff foramt. // It is assumed that the movie box contains fragment data. ISOMovie moov; MP4MovieFragmentAtomPtr moof; FILE *fp; fp = fopen(&...
Kundera's user avatar
  • 117
0 votes
1 answer
51 views

when muxing h264 to mp4 (isobmff format), Endian processing method

If video data muxing to mp4 file, video raw data -> mdat A typical MP4 layout: [MDAT size in 4 bytes] --> [MDAT header in 4 bytes "m","d","a","t"] then ...
Kundera's user avatar
  • 117
1 vote
1 answer
104 views

Python byte array equivalent in Rust

I'm looking to get this in rust: print(len(x).to_bytes(2, byteorder="little")) b'\n\x00 What is the equivalent to this in rust? How do I get this byte string? I need to send this string in ...
null's user avatar
  • 17
0 votes
0 answers
16 views

how do I find out the bit-endianness of the $BitMap file in NTFS

Before we get too into this, I'm not at all talking about byte-order-endianness. I'm talking about bit-order-endianness. Do we refer to the "zeroth" bit in a byte as the one that is least ...
stu's user avatar
  • 8,531
2 votes
5 answers
185 views

How do I read a binary file in BigEndian order to a record?

I have a binary file format that is written in BigEndian order. The files are of varying size so I can't use Sequential_IO for this, as I need to read different types. The problem is, when using ...
Adam's user avatar
  • 45
0 votes
1 answer
56 views

Socket.BeginReceive(): How handle big endian data on "ReceiveCallback"?

The following code (mirror in this sample) seems work fine to receive little endian data (tested), but i'm needing to receive big endian (from a Android phone) and any attempt to revert the bytes ...
JOTA's user avatar
  • 1
0 votes
1 answer
157 views

xxd vs od - little/big endian or something else going on

I am looking at a compiled java file on Ubuntu 22.04. On bash, when i say xxd A.class, i get a hexdump that begins with cafe babe - this is what i expect. But if i say od -x A.class, i get feca beba - ...
bukwyrm's user avatar
  • 186
2 votes
1 answer
42 views

Value changing when assigned to variable

I am writting a programm to decode a binary file. I am currently in test phase and I use phpunit. I tried to assign a two byte value into a variable but the value changed without any apparent reason. ...
Jean-Rémi Lapierre's user avatar
0 votes
1 answer
45 views

Notepad++ - swap endianess of values in text file

I have text file filled with hex values, six at each line, like this: 0XC71F2A11 0X46776208 0X448659B3 0X00000000 0X00000000 0XBFC3BAD1 0XC7122457 0X4680A201 0X448659B3 0X00000000 0X00000000 ...
jimpix's user avatar
  • 3
5 votes
1 answer
211 views

md5 hash calculation function failing

I'm trying to write an md5 hash function in R without calling any C-routines. While my code executes just fine, the output never matches tools::md5sum (which does match examples provided in various ...
Carl Witthoft's user avatar
0 votes
1 answer
70 views

Iterating efficiently in NumPy where next iteration depends on previous

I am trying to simulate arbitrary-precision binary arithmetic using NumPy. As a simple case, I have code (in basic, non-NumPy Python) that adds one to a binary number where binary numbers are ...
blandish's user avatar
  • 1,255
3 votes
2 answers
132 views

Does endianness affect the position of struct members in memory?

I'm working with bytes in C++ and was wondering about byte order in memory while taking padding between struct members into consideration, and whether endianness of the system affects the byte order ...
Feralnex's user avatar
0 votes
2 answers
156 views

How to cast int to Uint8 in Dart?

Currently, I am trying to read a file byte by byte and add some specific values to a list of 8-bit bytes (which might be of type List<Uint8>). To read the file one byte at a time, I am using ...
Xfce4's user avatar
  • 557
0 votes
2 answers
151 views

Reading a Fortran Data File in Python

I've been trying to read in a binary file that was apparently created using Fortran code. It's in .j03 format which is claimed to be some "old Fortran format". However, I am unable to read ...
gettingmathy's user avatar
0 votes
0 answers
19 views

Does ELF EI_CLASS endianness always match the target processor endianness

I'd like to know if ELF EI_CLASS endianness always match the target processor endianness ? When reading the ELF format I interpret ELFDATA2LSB and ELFDATA2MSB as the endianness of the ELF a.out file ...
Phi's user avatar
  • 755
-1 votes
2 answers
68 views

Do I need to handle endianess over an 8 bits bit-fields struct on a 32 bit architecture?

I am doing some embedded software on a 32 bits architecture (precisely AVR32). On this software I am retrieving a flag, coded on one byte, from an external peripheral connected via I2C. Each bits of ...
Amaury's user avatar
  • 73
0 votes
0 answers
17 views

Encoding and decoding information according the endian

I'm implementing the application layer of a communication protocol. I have to decode and encode byte arrays according several message specifications. The protocol specified little-endian for the ...
Albatros23's user avatar
1 vote
0 answers
60 views

Convert from DEC PDP-11 or Honeywell 316 to big endian unsigned int

How can i convert unsigned int variable to big endian if my endian is DEC PDP-11 or Honeywell 316 in C? Would it be correct to convert my unsigned int running on pdp endian to big endian like this: ...
dsfddg dggd's user avatar
1 vote
2 answers
76 views

Endianness & Storing Characters into Unsigned Integers

I am initializing a symlink in an ext2 inode (school assignment). I got the idea to do it in hex since the field is defined as uint32_t i_block[EXT2_N_BLOCKS]. As an example: #include <stdio.h> ...
user129393192's user avatar
1 vote
1 answer
69 views

Cannot understand how the gdb memory dump of my struct with bitfields is correct given my struct initialisation

I have designed a Packet struct for a custom networking protocol as follows: typedef struct { uint8_t src; uint8_t dest; uint8_t len; uint8_t flag; //bitfields allocated R-L? gcc ...
Armaan Chowfin's user avatar
0 votes
1 answer
112 views

Big Endian System - different output for same input

I am newbie to big endian system and trying to understand basic behaviour in it. I observed even when I assign same value to different data type, the value for u64 is different, while little endian ...
usav's user avatar
  • 1
2 votes
2 answers
50 views

Little endian and overwriting memory location

First of all I’ll make it clear that I know this piece of code is UB. Still I am not sure how this works. #include <stdio.h> int x[] = {1, 2, 3}; char s[] = "hello"; int main() { ...
SomeoneWithPassion's user avatar
2 votes
1 answer
127 views

How to reverse the "byte order" of a number in Ruby

I have a number I know to be representable as a 32-bit unsigned integer: num = 3735928559 # 0xDEADBEEF How would I (relatively easily) convert it to a number that is the representation of that ...
Michael Bonnet's user avatar
0 votes
1 answer
71 views

libpq error: ERROR: invalid byte sequence for encoding "UTF8": 0x00

I am trying to insert values to a postgresql table using libpq (in Binary Format). Below is my query insert into client_data (serverid,ipaddress,portid) values ($1,$2,$3) The data type for table ...
Rakesh Mehta's user avatar
-3 votes
1 answer
68 views

How to reverse the byte shifts after I have extracted a value in C?

void check_drop(char *drop_pathname) { FILE *fp; fp = fopen(drop_pathname, "rb"); int count = 0, pathname_length = 0, c; uint8_t drop_hash = 0, current_hash = 0; while ((...
Kenny's user avatar
  • 1
1 vote
0 answers
66 views

How does plc4j Modbus switch to big endian

My device only supports big-endian mode, plc4j uses little-endian by default, how does plc4j use big-endian mode I can't find a solution now
zq liu's user avatar
  • 11
0 votes
1 answer
201 views

What is the proper way to std::byteswap member bitfields in C++

I need to convert struct fields that came via network as raw bytes from big-endian to little-endian. Consider the following struct: struct [[gnu::packed]] Header { std::uint8_t magic_value:4; ...
blonded04's user avatar
  • 351
1 vote
2 answers
218 views

Generic function to byte swapping a struct in C

I know one way to byte swap a struct is to byte swap each individual member variables separately. Below is an example. #include<stdio.h> #include<byteswap.h> #define Uint16 ...
MajorBlackViking's user avatar
3 votes
2 answers
166 views

In C#, is boxing and unboxing involved when casting long to ulong and vice versa?

I know that boxing then unboxing is computationally expensive, and it happens when casting a value type to object or other reference type then back to value type. However, does this happen when I'm ...
8749236's user avatar
  • 444
-4 votes
2 answers
233 views

Storing in little or big endian [closed]

I am a bit confused whether my two functions are retrieving bytes and storing bytes into a char array. Now, in my system, I store integers into my char array (char *). I break them down into chunks of ...
HyperCoderSuperion's user avatar

1
2 3 4 5
43