# Re: Reverse (Mirror) Binary Number

• From: Tim Roberts <timr@xxxxxxxxx>
• Date: Sat, 02 May 2009 12:03:23 -0700

Arne Vajhøj <arne@xxxxxxxxxx> wrote:

Colmeister wrote:
This should be a simple task but I seem to be having a brain-block at the
moment.

I have a 6 bit number (0 - 63) that I need to reverse at the binary level,
e.g.

If the starting number is 5
The binary representation is 000101
The reversed binary representation is 101000
The result (which I need to be able to calculate) is 40

I can do this by converting the number to a string (or char array)
representation of the binary number, reversing it, and then converting back
to a number, but there must be a better method.

I would use a lookup table with 64 elements.

Absolutely. That's the way most FFT routines solve this problem.
--
Tim Roberts, timr@xxxxxxxxx
Providenza & Boekelheide, Inc.
.

## Relevant Pages

• Re: Reverse (Mirror) Binary Number
... Colmeister wrote: ... The reversed binary representation is 101000 ... I can do this by converting the number to a string representation of the binary number, reversing it, and then converting back to a number, but there must be a better method. ...
(microsoft.public.dotnet.languages.csharp)
• Reverse (Mirror) Binary Number
... This should be a simple task but I seem to be having a brain-block at the ... The reversed binary representation is 101000 ... I can do this by converting the number to a string ...
(microsoft.public.dotnet.languages.csharp)
• Re: Reverse (Mirror) Binary Number
... "Colmeister" wrote in message ... The reversed binary representation is 101000 ...
(microsoft.public.dotnet.languages.csharp)