FAQ Database Discussion Community

## Fast way to switch bits order? [closed]

java,c,go,byte,byte-order
I have a binary like this 10011011 My data store like this 10,01,10,11, but I want to reorder like this 11100110 The data look like 11,10,01,10.This operation same as ByteOrder convert but in bits level. Any fast bitop way to do this ? Currently, I have to decode this to...

## How to byte reverse NSData output in Swift the littleEndian way?

swift,nsdata,byte-order
Hey guys 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>?...

## What is the most significant byte of 160 bit hash for arithmetic operations?

c#,.net,sha1,dht,byte-order
Could somebody help me to understand what is the most significant byte of a 160 bit (SHA-1) hash? I have a C# code which calls the cryptography library to calculate a hash code from a data stream. In the result I get a 20 byte C# array. Then I calculate...

## Why do inet_ntoa and inet_ntop “reverse” the bytes?

c,networking,winsock,byte-order
This is a rather basic problem with which, to my surprise, I've had a problem today. It looks to me like inet_pton and inet_ntoa are reversing the bytes of the IP address they're given: DWORD IP; inet_pton(AF_INET, "192.168.0.1", &IP); printf("%08X\n", IP); This will print 0100A8C0. And well, if we break...

## Why conditional byte order is bad?

endianness,byte-order
Linus claims[12] that conditional byte order is worse than silly. The first thing comes to my mind is ZFS but surely there must be other examples. He wrote: The only sane model is to specify one fixed byte order. Seriously. It's equally portable, it generates better code - even on...