일반 OS는 big endian 방식임.
즉, uint a = 0x12345678; 0x12 34 56 78;
little endian으로 변경하면..
uint b = 0x12345678; -> 0x78 56 34 12 가 됨
// Big Endian을 little엔디안으로 return UInt32
static UInt32 _fnBigToLittleEndian_UInt(UInt32 bigNumber)
{
byte[] temp = new byte[4];
temp = BitConverter.GetBytes(bigNumber);
Array.Reverse(temp);
return BitConverter.ToUInt32(temp, 0);
}
// Big Endian을 little엔디안으로 return Byte[]
static Byte[] _fnBigToLittleEndian_Byte(UInt32 bigNumber)
{
byte[] temp = new byte[4];
temp = BitConverter.GetBytes(bigNumber);
return temp;
}
'프로그래밍 > .Net' 카테고리의 다른 글
Process kill 하기 (0) | 2014.01.17 |
---|---|
List 사용하기 (0) | 2014.01.17 |
C# Block Copy (memcpy) & string byte 상호 변환 (0) | 2014.01.17 |
C# 메모리 관리 - 마소 발췌 (0) | 2014.01.17 |
Drag & Drop 기능 구현하기 (0) | 2014.01.17 |