endianness Questions

3

Solved

In other words, according to the C standard, is this code safe? (Assume uint8_t is one byte) void detectEndianness(void){ union { uint16_t w; uint8_t b; } a; a.w = 0x00FFU; if (a.b == 0xFFU)...
Pro asked 22/11, 2017 at 9:7

2

Solved

2nd edit: I think my original test script has an issue, the 10000000 times loop is, in fact, dealing with the same memory location of an array, which makes the unsafe version (provided by Marc here...
Church asked 28/11, 2017 at 10:27

8

I haven't found a specific question here on SO, if this is a duplicate please point it out to me and I'll delete this. So really, does endianness have anything to do with bit order? This seems to...
Historicism asked 20/8, 2014 at 10:8

4

Solved

Given a char buffer c containing an int (little endian). How to read it as int32_t? I wrote this code but it doesn't feel idiomatic cpp. int32_t v; char* p = (char*)&v; for (int i=0; i < ...
Zoometry asked 7/10, 2017 at 12:0

1

Solved

I'm working on a PowerPC machine with in-core crypto. I'm having trouble porting AES key expansion from big endian to little endian using built-ins. Big endian works, but little endian does not. T...
Wiese asked 21/9, 2017 at 10:46

2

Solved

I have a byte array where the data in the array is actually short data. The bytes are ordered in little endian: 3, 1, -48, 0, -15, 0, 36, 1 Which when converted to short values results in: 259, ...
Playboy asked 12/2, 2013 at 7:18

2

Solved

Visual Studio defines _byteswap_uint64 and _byteswap_ulong in stdlib.h. Am I right to assume, that this is not standard and won't compile on Linux or Darwin? Is there a way to define these includ...
Nittygritty asked 20/1, 2017 at 19:19

5

My question is how do you convert a UINT32 value to a UINT8 array[4] (C/C++) preferably in a manner independent of endianness? Additionally, how would you reconstruct the UINT32 value from the UINT...
Discuss asked 27/6, 2011 at 21:31

1

Solved

edit: This is different from Endianness of Android NDK because that question asks how to find the endianness, not how many devices are big/little-endian. Mods, please don't mark this as a dupe. ...
Mchail asked 20/7, 2017 at 3:14

2

Solved

I have an little endian hex string that needs to be converted to a decimal in JavaScript. Example hex string: "12AB34CD" To get the correct value it need to swap the bytes to this: "CD34AB12" Cu...
Primary asked 31/5, 2017 at 14:41

4

Solved

How would I got about decoding the string below from basE91 to readable text using NodeJS? 8D7Hh-9D*.n-!DZrG-#DE-$DD-%DC-sl-tl-BEp2m-CE^Ul-DE}CH-EEE-FED-GEC-<l-=l-hE(.K-iEvqS-jEB-kEB-lEB-mEB-Rm...
Monocular asked 3/7, 2012 at 3:47

1

Solved

When I try to write in a file a binary files with value like this : public static main(String[] args){ ByteBuffer output = ByteBuffer.allocate(80); output.order(ByteOrder.BIG_ENDIAN); output.pu...
Spinode asked 22/5, 2017 at 14:14

3

I am trying to convert TIF / TIFF images to JPG which works fine but for few TIF images I am getting an IllegalArgumentException: Bad endianness tag (not 0x4949 or 0x4d4d). Exception : java.io.IO...
Longcloth asked 24/7, 2014 at 7:8

3

Solved

Update: This was fixed in GCC 8.1. I'm working on a function that stores a 64-bit value into memory in big endian format. I was hoping that I could write portable C99 code that works on both little...
Pitapat asked 8/4, 2016 at 10:41

2

Solved

0x0000000000400507 <main+28>: 74 0c je 0x400515 <main+42> 0x0000000000400509 <main+30>: bf 28 06 40 00 mov $0x400628,%edi .. 0x400507 <main+28>: 0x28bf0c74 I think shows ...
Hosey asked 16/5, 2011 at 13:48

1

Solved

I am wondering why when I copy a 16 bit number to a two byte array, it results in only copying to the first index of the array. My code is as follows: #include <iostream> #include <stdint...
Breadthways asked 15/11, 2016 at 11:31

6

Solved

I found out that algorithm (int C) for checkink if machine is bigindian or littleindian is int is_big_endian(void) { union { uint32_t i; char c[4]; } bint = {0x01020304}; return bint.c[0] ==...
Myeloid asked 24/2, 2012 at 13:26

3

Solved

Need to encode & decode byte-stream (containing non-ascii characters possibly), from/into uint16, uint32, uint64 (their typical C/C++ meaning), taking care of endianness. What is an efficient &...
Wulfila asked 9/3, 2011 at 5:36

3

Solved

Short question: how can I reliably distinguish between mips, mipsel, mips64 and mips64el on any linux distribution? Longer explanation: We provide statically built/distribution independent binari...
Hygrograph asked 18/8, 2011 at 0:17

3

Solved

I have this output from NSData: <00000100 84000c00 071490fe 4dfbd7e9> So how could I byte reverse it in Swift and have this output: <00000001 0084000c 1407fe90 fb4de9d7>?
Photoplay asked 12/5, 2015 at 15:25

1

Solved

This code works perfectly fine on Ubuntu 16.04 and prints correct value (ETHERTYPE_IP) when I toss around UDP bytes via loopback interface: #include <pcap.h> #include <iostream> #inclu...
Towns asked 5/9, 2016 at 9:37

3

Solved

I have to generate sha256 hashes of data that is in little endian form. I would like to know if I have to convert it to big endian first, before using the sha 256 algorithm. Or if, the algorithm is...
Clarenceclarenceux asked 7/6, 2011 at 18:10

3

Solved

I would like to convert a int32_t from host byte order to network byte order and vice versa. I know about the htonl() function and its variants, but this takes unsigned integers. Is there a standar...
Preside asked 2/2, 2011 at 19:12

3

Solved

In regards to htonl and ntohl. When would either of these two lines of code evaluate to false. htonl(x) == ntohl(x); htonl(ntohl(x)) == htonl(htonl(x)); In other words, when are these two ope...
Canikin asked 23/7, 2012 at 17:45

3

How do I convert big endian to little endian in ARM?
Trude asked 26/11, 2010 at 15:48

© 2022 - 2024 — McMap. All rights reserved.