Re: reversing a byte
- From: Eric Sosman <esosman@xxxxxxxxxxxxxxxxxxx>
- Date: Wed, 22 Mar 2006 08:30:48 -0500
Ajay wrote:
Hi all,can you please tell the most efficient method to reverse a
byte.Function should return a byte that is reversed.
Whence this unhealthy fascination with "most efficient?"
Two minutes ago you asked for the "most efficient" way to find
a substring, now you're asking for the "most efficient" way
to reverse a byte. What's next? The "most efficient" way to
listen to the Emperor Concerto?
For future reference: The C language says nothing about the
amount of time any operation requires, nothing about the amount
of space any executable code occupies, nothing about the power
consumption of the computer running the code, and very little
about the amount of space taken by data objects. Most notions
of "efficiency" incorporate one or more of these measures, so
questions about "efficiency" are usually unanswerable in terms
of C. They may be answerable for a particular implementation of
C on a particular computer, but in that case you should read
the documentation for that implementation or ask your question
in a forum devoted to that implementation; this is the wrong
forum for such questions.
... and if you'll accept a tiny bit of advice from a battle-
scarred veteran: "efficiency" is not the most important attribute
of a program. For example, here is the most "efficient" method
I can think of to solve your byte-reversal problem:
#define REVERSE_BYTE(x) 0
On most machines this will be faster and shorter than almost any
alternative you can come up with, and sometimes it will even give
the right answer. Use it in good health.
--
Eric Sosman
esosman@xxxxxxxxxxxxxxxxxxx
.
- Follow-Ups:
- Re: reversing a byte
- From: code break
- Re: reversing a byte
- From: Richard G. Riley
- Re: reversing a byte
- From: Ajay
- 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: CLC wiki: faq
- Previous by thread: Re: reversing a byte
- Next by thread: Re: reversing a byte
- Index(es):
Relevant Pages
|