472,325 Members | 1,080 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

candidate for bitset


Given an unsigned int variable that's part of a composite type
struct test {
unsigned int mask;
};

Assume 4 bytes for unsigned int. In one function, I'd like to set
any bit or combination of bits between bits 0 and 23 for the parameter
mask.

So lets suppose I set bits 5, 15 and 23 of mask.

In a separate function I'd like to decode that and store the location
of the bit that was set in a vector .. so in the vector I'd have 5, 15
and 23.

Is this a candidate for bitset? Cant seem to get that to work for me,
then again I'm probably on the wrong track. Trying to determine a way
to make this seemless.

Thanks in advance...

Dec 14 '05 #1
2 1276
ma740988 wrote:
Given an unsigned int variable that's part of a composite type
struct test {
unsigned int mask;
};

Assume 4 bytes for unsigned int. In one function, I'd like to set
any bit or combination of bits between bits 0 and 23 for the parameter
mask.

So lets suppose I set bits 5, 15 and 23 of mask.

In a separate function I'd like to decode that and store the location
of the bit that was set in a vector .. so in the vector I'd have 5, 15
and 23.

Is this a candidate for bitset? Cant seem to get that to work for me,
then again I'm probably on the wrong track. Trying to determine a way
to make this seemless.


Just have fun and implement your own "bitset". What do you think you
can use from std::bitset? 'set' and 'reset'? And std::bitset has no
enumeration, really. So, you'd have to loop over the collection anyway.
Why not challenge your brain to a bit of coding once in a while? :-)

V
Dec 14 '05 #2
Happy holidays Vic.
|| Why not challenge your brain to a bit of
|| coding once in a while? :-)
Ok

Dec 14 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Hunter Hou | last post by:
Hello, I have this very simple program, but it can't be compiled. What's wrong here? thanks, hunter #include <iostream>
2
by: shaun roe | last post by:
As a follow up to my question about STL and bitset<64> I'd like to share a quirk (bug?) about unsigned long long support and the bitset. I'm using...
5
by: SpOiLeR | last post by:
Hi. q1: Is std::bitset<N> part of standard or it's compiler extension? q2: Is std::bitset::to_string() part of standard? q3: My...
5
by: Rich S. | last post by:
Hi, Is the code below the best way to have the less than function for an 80 bit bitset or is there something faster / better? When I populate...
14
by: Haro Panosyan | last post by:
How to construct a bitset from string? For example: std::bitset<16> b16("1011011110001011"); Is this possible? Thanks in advance. -haro
3
by: shaun | last post by:
I have a function for returning the value of a bit field in a number: template<typename T> T bitfield(const T num, const unsigned int bitStart,...
4
by: Sarath | last post by:
>From the documentation of MSDN, it is saying that bitset is not a STL container Unlike the similar vector<boolClass, the bitset class does not...
2
by: arnuld | last post by:
i am confused on some aspects of bitset class: /* C++ Primer 4/e * chapter 3 * * exercise 3.23 * */ #include <iostream>
5
by: swcamry | last post by:
class bitset::reference { friend class bitset; reference(); // no public constructor public: ~reference();...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

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.