473,725 Members | 2,168 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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;

Thanks for your help.
Aug 16 '06 #1
1 3722
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

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

Similar topics

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
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 = "delia";
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 there any function to do this? The function should return e.g a char** in which each line is. Thanks in advance :)
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 strings or char arrays, doesn't matter... anyone know? Thanks in advance!
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 written code that reads the input table and writes to an output table with each delimited list parsed out. So if the delimited list has 4 entries, 4 output records are created, corresponding to the one input record.
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 types or std::vector<int>. So where I would use an int* and reallocate it from time to time in C, and randomly access it via , then I figure to copy the capacity and reserve methods, because I just need a growable array. I get to considering...
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" MFC C++? Thanks Sam
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. Would you please tell me if you know it? Thanks, Peng
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() ) { String token = s.next(); if ( token.length() == 1 && (token == "." || token == ";" || token == "," || token == ":") ) { continue;
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.