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

-Collapse +Expand C# To/From
-Collapse +Expand C# Study Test
-Collapse +Expand C# Store

Prestwood eMagazine

April 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  
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,
 Posted 20 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=4241
Last Reply Posted 1/3/2010 10:20:06 PM)
Joined=20 years ago   MB Posts=1  
Most Recent Post
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.



 Posted 11 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=14 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 = P1107A1
Enter key:
Icon: A Post    Thread    Idea    Important!    Cool    Sad    No    Yes    Includes a Link...   
Thread #4003 Counter
Since 4/2/2008

Follow PrestwoodBoards on: 

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