473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Split a vector

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;

Thanks for your help.
Aug 16 '06 #1
1 3703
Banfa
9,065 Expert Mod 8TB
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) & 0x000000000FFFFFFF
F1 = Y & 0x000000000FFFFFFF
Aug 16 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: alexk | last post by:
I've a simple question. Why the following: words = "123#@$#$@^% wordB#@$".split('~`!@#$%^&*()_+-={},./') doesn't work? The length of the result vector is 1. I'm using ActivePython 2.4 Alex
15
by: zealotcat | last post by:
Hi, all: I want to implement a function (using std::string and std::vector) split a string contain special token into vector. eg: string = "alex delia john" ==> vector = "alex"; vector =...
4
by: Daniel Pomrehn | last post by:
Hello :) I've got a string in a char* variable. This string is entered by the user and it can contain some \n Now I want to split the entered text by this char into different strings. Exists...
11
by: | last post by:
Hello everyone! :-D OK, I've came across many functions for this, but none works! I need one that works like this: StringSplit(string str, string delim, vector<string> results) Either with...
2
by: ThurstonHowl | last post by:
Hello, my task is the following: Input are tables with fields containing strings where the strings are actually delimited lists. For example, one field could contain 'AB|CD|EF|GH' I've...
8
by: Ross A. Finlayson | last post by:
I'm trying to write some C code, but I want to use C++'s std::vector. Indeed, if the code is compiled as C++, I want the container to actually be std::vector, in this case of a collection of value...
1
by: Sam Johnson | last post by:
Hi I've seen that the string classes in the .net framework have a cool (new?) function: splitting strings and returning the substrings in an array. Is there any equivalent to this in "old-style"...
5
by: PengYu.UT | last post by:
In perl, I can do the following thing to split a string. my ($benchmark, $suffix) = split(/\./, $fullbenchmarks); I'm wondering if there is similar thing in C++ which can do the same thing....
5
mickey0
by: mickey0 | last post by:
hello, I have to read a text and I decided to split it with Scanner class. private Vector<String> splitWords(Scanner s) { Vector<String> v = new Vector<String>(); while ( s.hasNext() )...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.