What is the most efficient way to read a bit at a particular position in a byte?
What is the most efficient way to read a bit at a particular position in a byte?
Bitwise operations.
Not sure if it's the most efficient way possible, but this is one way to do it with bitwise operators:
Code:unsigned char myByte; ... myByte <<= position; int myBit = myByte & 1;
How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.
Unrepentant and irredeemable cross-poster -> Most Efficient Way To Read A Bit From A Byte? - C And C++ | Dream.In.Code
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
So what if I posed the same question in another forum?
That's how you get more variety of answer from more people since there's obviously more than one C++ forum on the Internet.
Different story if I posted the same question on the same forum..
It's called cross-posting. To understand why it is frowned upon you must recognize that the people here are helping others voluntarily and in their own time, and so are the people on dreamincode. When cross-posting, there is a duplication of effort. My response for example was unnecessary since you already got a better and more thorough explanation in another forum, so the time i spent typing out my reply is wasted. I could've spent that time doing other things or helping someone else. Basically, you're wasting our time.
How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.
I'm not after a single answer. I am after a variety of answers/opinions. This is a discussion board after all, and it is voluntary as you said.
It's no different to going to the city and asking random people questions. You don't stop just because one person gave you a good/better answer, or because someone else had the same answer as a previous person, and none of the people you asked would care if they knew it.
Giving effort to answer someones question on the Internet with the expectation that that answer is unique does not exist.
That doesn't mean I don't appreciate your participation. In the end, that's what counts.
Bad analogy. Ask a mechanic what is wrong with your car, listen to his long and thorough reply, and then immediately ask his colleague the same question. You're insinuating that the first answer was not satisfactory, and you've wasted his time and effort, you can be certain he will not be as helpful the next time around.
In the end, it doesn't really matter what your opinion of crossposting is. You were told on dreamincode that it is frowned upon, and you have been told the same thing here. Do you know the expression 'biting the hand that feeds you'?Giving effort to answer someones question on the Internet with the expectation that that answer is unique does not exist.
That doesn't mean I don't appreciate your participation. In the end, that's what counts.
How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.
Many would.
If you got a good answer from someone who explained it enthusiastically to you, and the next moment, in front of him...you decide to ask a random stranger....that is somewhat insulting to the first person.
That generally means that you are not satisfied with the answer or that the answer isn't really important to you and you're asking just for the sake of asking (which seems to be the case here).
When I have spare time I help people on forums too, I don't question them or if they 'cross-posted' as it is irrelevant to me as they obviously asked the question for a reason. If you feel it's a 'waste of time' then please do not participate in my questions anymore.
I had a feeling I might be needing bitwise.
Thanks everyone for your answers. I really appreciate your help.
I should be able to manage from here on.
Last edited by Tom50; 03-30-2013 at 06:46 PM.
Everyone here is just trying to give you the advice that crossposting is generally frowned upon. You may have no qualms about it, but that does not mean others do not.
If you find a thread that is crossposted, then posting in one of those threads is your prerogative. No one is going to stop you.
However, when you post questions, you should take into account that people do find it rude if you crosspost it, at the very least if you don't mention that you have done so (and possibly provided links). That's all we're asking.
If you would just acknowledge that, then people will stop trying to reply further on the matter and perhaps you can get some answers to your questions (though that is doubtful considering you did crosspost).
Nothing better than starting a conversation about something you don't care you did!So what if I posed the same question in another forum?
You might want to follow this link for an explanation of what is happening.
There are two significant groups of participants in a forum. The first group is made of those people who ask questions. The second group is made of up those people who answer them. The first group relies on the second. The second group, unless they are paid hard cash to answer questions, does not rely on the first.
If people who answer questions write you off as a loser - i.e. not worth their effort to help you - they will stop helping you. One of the primary ways of getting written off as a loser is to cross-post. Why? Because, in practice, people in the second group know their counterparts on other forums.
The way you're going, it appears this will be at least the second forum where you get written off as a loser.
Last edited by grumpy; 03-30-2013 at 11:22 PM.
Try this thought experiment.
1000 newbies randomly pick ONE forum out of 1000 and ask their question. The average number of posts per forum is therefore 1, and it will get the FULL attention of the forum residents.
vs.
1000 newbies all cross-post ONE question over all 1000 forums. The average number of posts per forum is now 1000, and nobody will give a ........ because each forum has been flooded, and every forum resident knows that the question is asked in many places, so there is no value in even trying to help, because the answer is likely duplicated elsewhere.
You see, you're the thin end of the wedge that is case 2. If we tolerate your behaviour to the point that it becomes the norm, then some future self-important jerk will up the ante and post on 3 forums instead of 2.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.