# MSB and LSB

Page 1 of 1

## 1 Replies - 7294 Views - Last Post: 22 January 2010 - 08:50 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=151361&amp;s=6515e651c0efd9509e91eb349fd90077&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 tommynator128

Reputation: 8
• 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

• New D.I.C Head

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

## Re: MSB and LSB

Posted 22 January 2010 - 08:50 AM

tommynator128, 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);
```