# How to split a binary data to form two split binary data?

I want to split a received binary data into two binary data.

Take the following received binary data for instance:

``````uint32_t data = 0xFFFF0001;
``````

In binary format it is: 11111111111111110000000000000001

If we need to split this above binary into two new binary data how could it be done?

As an example from the 0xFFFF0001, how can we obtain the first 17-bit as as data1 = 11111111111111110 and then the remaining 15-bit as data2 = 000000000000001 ?

You can use the `bit shift` and `and` operator, like:

``````uint32_t data = 0xFFFF0001;
``````

The following line will shift all bits 15 places to the right, meaning the least significant 15 bits will be removed, and the other bits shifted to the right.

``````uint32_t dataLeft = data >> 15;

11111111111111110000000000000001
>>>>>>>>>>>>>>>11111111111111110000000000000001
| Bit shift   || orig. bits    ||Removed bits |
``````

For the other 15 bits, you can use the `and` operator, which just makes all 1's 0's for those bits not in the bit mask (0x7FFF).

``````uint16_t dataRight = data & 0x7FFF;

value:              11111111111111110000000000000001