CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Simple bit shift?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Will Reeve



Joined: 30 Oct 2003
Posts: 209
Location: Norfolk, England

View user's profile Send private message Send e-mail Visit poster's website MSN Messenger

Simple bit shift?
PostPosted: Fri Apr 03, 2009 4:45 am     Reply with quote

Hi,
Really a C question but there must be a very elegant way to do but I can't latch onto it at the moment, the problem is this:

I need to reverse a byte bit-wise, say the bits in a byte are conventional. IE:

76543210

I need it mirrored to have the bits arranged:

01234567

so (in decimal) 1 would become 128 2 becomes 64 etc?
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Fri Apr 03, 2009 5:32 am     Reply with quote

This problem has been discussed in Reverse order of bits.
Several algorithms were tested and a very fast and elegant solution was found.
Will Reeve



Joined: 30 Oct 2003
Posts: 209
Location: Norfolk, England

View user's profile Send private message Send e-mail Visit poster's website MSN Messenger

PostPosted: Fri Apr 03, 2009 8:49 am     Reply with quote

Thanks, interesting discussion!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group