Click here to Skip to main content
15,929,833 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Finding number of bits set in a given number Pin
toxcct7-Mar-06 0:51
toxcct7-Mar-06 0:51 
GeneralRe: Finding number of bits set in a given number [fixed] Pin
David Crow7-Mar-06 3:42
David Crow7-Mar-06 3:42 
GeneralRe: Finding number of bits set in a given number [fixed] Pin
toxcct7-Mar-06 3:44
toxcct7-Mar-06 3:44 
AnswerRe: Finding number of bits set in a given number Pin
Stephen Hewitt7-Mar-06 0:32
Stephen Hewitt7-Mar-06 0:32 
GeneralRe: Finding number of bits set in a given number Pin
toxcct7-Mar-06 0:34
toxcct7-Mar-06 0:34 
GeneralRe: Finding number of bits set in a given number Pin
Stephen Hewitt7-Mar-06 0:52
Stephen Hewitt7-Mar-06 0:52 
GeneralRe: Finding number of bits set in a given number Pin
toxcct7-Mar-06 0:56
toxcct7-Mar-06 0:56 
GeneralRe: Finding number of bits set in a given number Pin
Stephen Hewitt7-Mar-06 3:06
Stephen Hewitt7-Mar-06 3:06 
v2.0 wrote:
because it expands the bits to the array, and as the minimum unit that can be addressed is the byte


That is not how bitsets work. They store the data as bits and use bit operations ("and" & "or", etc) to address them. It has an embedded class called reference that makes this seamless but it does happen. Here's some code from MSVC6's implementation (I altered the formatting):
bitset<_N>& set(size_t _P, bool _X = true)
{
     if (_N <= _P)
         _Xran();
     if (_X)
         A[_P / _Nb] |= (_Ty)1 << _P % _Nb;
    else
        _A[_P / _Nb] &= ~((_Ty)1 << _P % _Nb);
    return (*this);
}


This is the whole idea behind bitsets - To have the notational convince without space overheads you alluded to above.


Steve
GeneralRe: Finding number of bits set in a given number Pin
toxcct7-Mar-06 3:12
toxcct7-Mar-06 3:12 
GeneralRe: Finding number of bits set in a given number Pin
Stephen Hewitt7-Mar-06 11:53
Stephen Hewitt7-Mar-06 11:53 
GeneralRe: Finding number of bits set in a given number Pin
BadKarma7-Mar-06 12:17
BadKarma7-Mar-06 12:17 
AnswerRe: Finding number of bits set in a given number Pin
Chris Losinger7-Mar-06 2:07
professionalChris Losinger7-Mar-06 2:07 
GeneralRe: Finding number of bits set in a given number Pin
toxcct7-Mar-06 2:25
toxcct7-Mar-06 2:25 
GeneralRe: Finding number of bits set in a given number Pin
Blake Miller7-Mar-06 3:23
Blake Miller7-Mar-06 3:23 
GeneralRe: Finding number of bits set in a given number Pin
toxcct7-Mar-06 3:27
toxcct7-Mar-06 3:27 
GeneralRe: Finding number of bits set in a given number Pin
BadKarma7-Mar-06 2:30
BadKarma7-Mar-06 2:30 
AnswerRe: Finding number of bits set in a given number Pin
Gary R. Wheeler7-Mar-06 2:51
Gary R. Wheeler7-Mar-06 2:51 
GeneralRe: Finding number of bits set in a given number Pin
toxcct7-Mar-06 2:53
toxcct7-Mar-06 2:53 
GeneralRe: Finding number of bits set in a given number Pin
Gary R. Wheeler7-Mar-06 2:59
Gary R. Wheeler7-Mar-06 2:59 
AnswerRe: Finding number of bits set in a given number Pin
BadKarma7-Mar-06 6:03
BadKarma7-Mar-06 6:03 
QuestionDirectShow SDK download Pin
Storm-blade7-Mar-06 0:03
professionalStorm-blade7-Mar-06 0:03 
AnswerRe: DirectShow SDK download Pin
Justin Tay7-Mar-06 5:26
Justin Tay7-Mar-06 5:26 
AnswerRe: question Pin
toxcct7-Mar-06 0:01
toxcct7-Mar-06 0:01 
QuestionUsing VC7.1 compiler under VC6 IDE.... woes.... :S Pin
kevingpo6-Mar-06 23:52
kevingpo6-Mar-06 23:52 
AnswerRe: Using VC7.1 compiler under VC6 IDE.... woes.... :S Pin
toxcct6-Mar-06 23:59
toxcct6-Mar-06 23:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.