Re: reversing a byte
- From: "Charles Mills" <cmills@xxxxxxxxxxxxx>
- Date: 21 Mar 2006 23:23:13 -0800
Charles Mills wrote:
Ajay wrote:---8<---- sniped totally wrong lookup table ---8<----
Hi all,can you please tell the most efficient method to reverse a
byte.Function should return a byte that is reversed.
Use a look up table (untested generated code below):
static unsigned char
reverse_byte(unsigned char b)
{
static const unsigned char b_tbl[] = {
};
return b_tbl[b];
}
-Charlie
probably want something like this:
static const unsigned char b_tbl[] = {
0x0, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
...,
0xf, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
};
you can fill in the blanks.
-Charlie
.
- Follow-Ups:
- Re: reversing a byte
- From: CBFalconer
- Re: reversing a byte
- References:
- reversing a byte
- From: Ajay
- reversing a byte
- Prev by Date: Re: Parsing a Section of Binary String Data!
- Next by Date: Re: Parsing a Section of Binary String Data!
- Previous by thread: Re: reversing a byte
- Next by thread: Re: reversing a byte
- Index(es):