1 Replies - 4753 Views - Last Post: 22 January 2010 - 08:50 AM Rate Topic: -----

#1 tommynator128  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 8
  • View blog
  • Posts: 127
  • Joined: 05-January 10

MSB and LSB

Posted 22 January 2010 - 08:40 AM

hi,

how can i convert a char from msb->lsb and lsb->msb in c++?

many thx
tommy

This post has been edited by tommynator128: 22 January 2010 - 08:41 AM

Is This A Good Question/Topic? 0
  • +

Replies To: MSB and LSB

#2 mahdavi110  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 4
  • Joined: 22-January 10

Re: MSB and LSB

Posted 22 January 2010 - 08:50 AM

View Posttommynator128, on 22 Jan, 2010 - 07:40 AM, said:

hi,

how can i convert a char from msb->lsb and lsb->msb in c++?

many thx
tommy


you mean to reverse bits ?

unsigned char revchar ( char a ) 
{
	  unsigned char res = 0;
	  for ( long i = 0; i < 8; i ++ ) 
	  {
			res =( res >> 1) | ((a & 0x1)<< 7); 
			a /=2; 
	  }
}


char x = 'b'; 
char y = revchar (x); 

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1