please guide me....i didnt know how to implement its...

my situation is like this :-

let say that i have 11111010..... And i want to move the left most side of binary number and add with the 4 bits in the right side, so its can be like this

. 1010
+ 1111

How are you representing the binary numbers?

## All 2 Replies

How are you representing the binary numbers?

From your description, you are using 8-bit values, and want to extract the high and low nibbles (4 bits), turn them into 4-bit values, then add them together? Is that correct? If so, then what you want to is a mask and shift operation. Example:

``````unsigned char ch = 11111010b; // unsigned 8-bit value
unsigned char top = (ch & 0xF0) >> 4; // Mask off bottom 4 bits and shift right
unsigned char bottom = (ch & 0x0F);   // Mask off top 4 bits - no need to shift
unsigned int results = top + bottom;  // Add top and bottom values``````
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.