//////////////////////////////////////////////////////////////////
//
// MSB : most significant bit/byte
//
// bit : 최상위 비트
// byte : 최상위 바이트
//
// MSB<0>::bit == 0
// MSB<0>::byte == 0
// MSB<1>::bit == 1
// MSB<1>::byte == 1
// MSB<0x100>::bit == 9
// MSB<0x100>::byte == 2
// MSB<0x101>::bit == 9
// MSB<0x101>::byte == 2
// MSB<0x10000000>::bit == 32
// MSB<0x10000000>::byte == 4
// MSB<0x10000001>::bit == 32
// MSB<0x10000001>::byte == 4
//
//////////////////////////////////////////////////////////////////

template<DWORD N>
struct MSB
{
static unsigned const bit = MSB<(N>>1)>::bit + 1;
static unsigned const byte = MSB<(N>>8)>::byte + 1;
};

template<>
struct MSB<0>
{
static unsigned const bit = 0;
static unsigned const byte = 0;
};


//////////////////////////////////////////////////////////////////
//
// LSB : least significant bit/byte
//
// bit : 최하위 비트
// byte : 최하위 바이트
//
// LSB<0>::bit == 0
// LSB<0>::byte == 0
// LSB<1>::bit == 1
// LSB<1>::byte == 1
// LSB<0x100>::bit == 9
// LSB<0x100>::byte == 2
// LSB<0x101>::bit == 1
// LSB<0x101>::byte == 1
// LSB<0x10000000>::bit == 32
// LSB<0x10000000>::byte == 4
// LSB<0x10000001>::bit == 1
// LSB<0x10000001>::byte == 1
//
//////////////////////////////////////////////////////////////////

template<DWORD N>
struct LSB_temp
{
static unsigned const bit = LSB_temp<(N<<1)>::bit + 1;
static unsigned const byte = LSB_temp<(N<<8)>::byte + 1;
};

template<>
struct LSB_temp<0>
{
static unsigned const bit = 0;
static unsigned const byte = 0;
};

template<DWORD N>
struct LSB
{
static unsigned const bit = 33-LSB_temp<N>::bit;
static unsigned const byte = 5-LSB_temp<N>::byte;
};

template<>
struct LSB<0>
{
static unsigned const bit = 0;
static unsigned const byte = 0;
};

'자료 > 내자료' 카테고리의 다른 글

SPE V1 - 길찾기용 지형구조  (9) 2006.12.10
게임을 위한 GUI모듈  (4) 2006.07.31
is_template  (0) 2006.05.10
분절 모델의 접합부위 Normal값 수정  (0) 2006.02.23
enum string  (0) 2005.07.08

+ Recent posts