Re: reversing a byte



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
.



Relevant Pages

  • Re: SPOILER: Independent 26/05/08 (was Re: SCWC 52 Results)
    ... *not* a definition and no amount of saying it loud will make it one. ... As I understand it the debate is whether the clue ... cryptic crossword purposes. ... the reverse of a definition - DIAL + a reversal indicator in the clue where ...
    (rec.puzzles.crosswords)
  • Re: Sheddi Taxidermy
    ... years driving still doesn't amount to the price of a single ordinary ... NUNS! ... Reverse!" ...
    (uk.rec.sheds)
  • Re: Photo ***Message Marked as SPAM*** Ignore
    ... wastes people's time it becomes something else. ... and no amount of liberal arts waffle makes it otherwise. ... The reverse is also ...
    (alt.photography)
  • RE: Deriving Exactly XXX Amount of Weekdays
    ... (in reverse) ... Luke M ... "Rob" wrote: ... Either of the cells can hold any date and any amount ...
    (microsoft.public.excel.worksheet.functions)