473,725 Members | 2,168 Online

# Split a vector

51 New Member
Please, I have a verctor of 64 bits like this Y = 00000000 1111000 0110011 0010101 0101111 0101010 1011001 1001111 0001111, and I want to split it in two vectors (each one of 28 bits) like this:

F1 = Y(8 to 35); I mean This vector is from bit 8 to bit 35, reading Y from left to right, you know bit 1 is 0, 2 is 0 and 64 is 1

F2 = Y(36 to 64); so the vector would be;

F1 = 1111000 0110011 0010101 0101111 ;
F2 = 0101010 1011001 1001111 0001111;

Aug 16 '06 #1
1 3722
Banfa
9,065 Recognized Expert Moderator Expert
Just use bit arimthmatic to get out the bits you want.

Normally when talking about bits it is usual for the least significant bit to be bit 0 (so a 32 bit number would have bits 0 - 31) and the most significant bit to appear on the left (as we do in decimal) and writing out binary numbers it is normal to group the bits in bytes (i.e. 8 bits per group) not 8 bits in the first group and seven there after.

F1 = (Y >> 28) & 0x000000000FFFF FFF
F1 = Y & 0x000000000FFFF FFF
Aug 16 '06 #2