Difference between revisions of "C 0000003 mmmv bit endianness byte t1"

From commentsarchive
Jump to: navigation, search
m
m
Line 52: Line 52:
  
 
<span style="color:red;">TODO: add demo C code that assigns values to 2 2B char array.</span>
 
<span style="color:red;">TODO: add demo C code that assigns values to 2 2B char array.</span>
 +
 +
 +
 +
= Related Topics =
 +
 +
* [[File:2021 01 20 The byte-order mark BOM in HTML ux-generated files.pdf]]

Revision as of 09:49, 20 January 2021

C 1..100


An assumption is that all bytes in a byte-stream have the same bit endianness. The purpose of the bit endianness byte is to allow software to figure out, whether it needs to reverse the order of bits in every byte of the byte-stream to make their order match with the CPU bit endianness. To allow the software to figure out the byte endianness of the CPU, at least 2 bytes must be used.


$$ BitEndiannessTestingByte0=01000000_{2}=40_{16}=64_{10} $$

$$ BitEndiannessTestingByte1=00100000_{2}=20_{16}=32_{10} $$


$$ ReverseBitOrder(01000000_{2})=00000010_{2}=2_{16}=2_{10} $$

$$ ReverseBitOrder(00100000_{2})=00000100_{2}=4_{16}=4_{10} $$


X ReverseBitOrder(X)
$64_{10}$ $2_{10}$
$32_{10}$ $4_{10}$


bit order byte order byte at index 1 byte at index 0 2B bitstream (index_1,index_0) 2B base 10
little-endian little-endian $32_{10}$ $64_{10}$ 0010000001000000 8256
little-endian big-endian $64_{10}$ $32_{10}$ 0100000000100000 16416
big-endian little-endian $4_{10}$ $2_{10}$ 0000010000000010 1026
big-endian big-endian $2_{10}$ $4_{10}$ 0000001000000100 516


TODO: add demo C code that assigns values to 2 2B char array.


Related Topics