I.T. Discussion Community!
-Collapse +Expand
C#
Search C# Group:

Advanced
-Collapse +Expand C# To/From
To/FromCODEGuides
-Collapse +Expand C# Study Test
PRESTWOODCERTIFIED
-Collapse +Expand C# Store
PRESTWOODSTORE

Prestwood eMagazine

November Edition
Subscribe now! It's Free!
Enter your email:

   ► MB LobbyC# (Visual C# & VS.Net) BoardC# & WinForms Topic   Print This     

Byte stored in reverse order

Byte stored in reverse order in C# & WinForms topic (part of our C# (Visual C# & VS.Net) group).

Quick Search: reverse   Byte stored   Byte stored reverse  
le-cardinal
 (Inactive)
FRANCE
Hi all,

I would to read a byte (unsigned char) and to store it in reverse order (b8...b1 becomes b1...b8).
What is the best solution in Code and Time performance to writ this in C?

Thanks for yours reply,
Daniel
 Posted 18 years ago (Thread Starter)
Comment Quote
About le-cardinal -Collapse +Expand
Visit Profile
Inactive member.
Member does not subscribe to this thread.
Email Not Verified!
Once email is verified, we will review and approve the account.
Web Presence Hidden.
Once above is taken care of, full Profile content will display including back links, about me, my message, custom Profile html, social networking links, message board signature, company profile, etc.

Post ID #4003, 1 replies
Thread Started 10/8/2001 7:49:00 AM
View Counter=4093
Last Reply Posted 1/3/2010 10:20:06 PM)
Location=FRANCE  
Joined=18 years ago   MB Posts=1  
Most Recent Post
Moderator
Bryan Valencia
209 Software
Home office in Manteca, CA

in general, this function will reverse a single byte.

        public static byte reverse(byte b)
        {
            byte answer = 0;
            for (int i = 0; i < 8; i++)
            {
                if ((b >> i & 0x1) == 1)
                {
                    answer += (byte)(1 << (7-i));
                }
            }
            return answer;
        }

Yahoo ID: Commander_Bombast

Opportunity is missed by most because it is dressed in overalls and looks like work.

--THOMAS ALVA EDISON

 

 Posted 9 years ago
Comment Quote
About Bryan Valencia -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
About Bryan Valencia

Bryan Valencia is the author of millions of lines of code and writes for PrestwoodBoards and Visual Studio Journey on-line magazines.

Web Presence
LinkedIn, Bryan On LinkedIn (Visit Me)
Website, Software Services (http://209software.com/)
Website, Visual Studio Journey (http://vstudiojourney.blogspot.com/)

Post ID #13827 (Level 1.1)  Reply to 4003
Thread Started 1/3/2010 10:18:40 PM
Location=Home office in Manteca, CA 
Joined=12 years ago   MB Posts=23   KB Posts=27   KB Comments=4   BLOG, Topics=2  

Revive Thread!

Add a comment to revive this old thread and make this archived thread more useful.

Write a Comment...
Full Editor
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1182A1
Enter key:
Icon: A Post    Thread    Idea    Important!    Cool    Sad    No    Yes    Includes a Link...   
Thread #4003 Counter
4093
Since 4/2/2008

Follow PrestwoodBoards on: 


©1995-2019 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech