Prepare for your Next Interview
This is a discussion on I need to reverse the bits in a short integer within the C and C++ forums, part of the Software Development category; I have short integer i need to reverse the bits in it ie first 8 bits in the second 8 bits position and second 8 bits in first 8 bit ...
|
|||
|
I need to reverse the bits in a short integer
I have short integer i need to reverse the bits in it ie first 8 bits in the second 8 bits position and second 8 bits in first 8 bit position?
Question asked by visitor Philip |
| Sponsored Links |
|
|||
|
short int x,y; ( 16 bit )
y = x && 0X00ffh ; x = x && 0X0ff00h ; x = x << 8 ; y = y << 8 ; x = x || y; Printf(" Exchange value is in x = %d",x); |
|
|||
|
How to reverse the bits in a short integer in Java
Code:
int x = i & 0x00FF;
int y = i & 0xFF00;
x = x << 8;
y = y >> 8;
System.out.println("");
System.out.println(x | y);
-dibyaranjan |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to learn basic XML in short time | mounesh4k | AJAX & XML | 3 | 12-05-2007 03:02 PM |
| How do I reverse a string with sql query only? | swanand11may | SQL | 4 | 07-09-2007 06:15 AM |
| values of bits from 4th to 12th position is my required final data | shivaram.cunchala | C and C++ | 1 | 06-21-2007 11:44 PM |
| What is the next integer in this series? | Manojks | Brainteasers | 5 | 01-18-2007 07:03 AM |
| Please give a Short and Crisp Answer | janelyn | Interviews | 1 | 07-29-2006 04:12 PM |