Click here to Skip to main content
15,892,161 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: gdi+ example ? Pin
Hamid_RT22-Jan-07 5:46
Hamid_RT22-Jan-07 5:46 
Questionabout a = b | c | ... Pin
HOW WHAT21-Jan-07 2:50
HOW WHAT21-Jan-07 2:50 
AnswerRe: about a = b | c | ... Pin
Gary R. Wheeler21-Jan-07 3:02
Gary R. Wheeler21-Jan-07 3:02 
GeneralRe: about a = b | c | ... Pin
HOW WHAT21-Jan-07 3:19
HOW WHAT21-Jan-07 3:19 
GeneralRe: about a = b | c | ... Pin
Gary R. Wheeler21-Jan-07 4:28
Gary R. Wheeler21-Jan-07 4:28 
AnswerRe: about a = b | c | ... Pin
CPallini21-Jan-07 3:37
mveCPallini21-Jan-07 3:37 
GeneralRe: about a = b | c | ... Pin
HOW WHAT21-Jan-07 3:57
HOW WHAT21-Jan-07 3:57 
GeneralRe: about a = b | c | ... Pin
CPallini21-Jan-07 4:55
mveCPallini21-Jan-07 4:55 
What I mean is that if you have b,c,d,e,f,... each corrensponding to only one bit set, for instance:
b=0x00000001;// bit 0 set
c=0x00000002;// bit 1 set
d=0x00000004;// bit 2 set
e=0x00000008;// bit 3 set
f=0x00000010;// bit 4 set


then a condition using (a & b) evaluates to true (non-zero) only if a has the bit 0 set and the same holds for a condition using ((a & b) == b). In the same way, a condition using (a & c) evaluates to non-zero only if a has the bit 1 set, the same holding for a condition using ((a & c)==c), and so on...

On the other hand, suppose that x is a combination (sum using OR) of the above indipendent values, for instance x= b | e;, so that x=0x00000009, i.e. x has both the bits 0 and 3 set.
In this case, a condition using (a & x) evaluates to non-zero either if a has:
<list>
  • only bit 0 set
  • only bit 3 set
  • both bit 0 and 3
  • while a condition using ((a & x) == x) holds true only if both bit 0 and 3 are set.

    In other words, if x = 0x00000009; then

    (a & x) holds true if a = 0x00000001;, or a = 0x00000008;, or a = 0x00000009;

    while ((a & x) == x) holds true if a = 0x00000009.



    hope that helps
    Smile | :)

    BTW both conditions are also true if a = 0x00000019 and so on...






    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
    -- Alfonso the Wise, 13th Century King of Castile.

    QuestionSome basic Qs abt MFC,VC++,SDK.... Pin
    Sameer_Thakur21-Jan-07 1:01
    Sameer_Thakur21-Jan-07 1:01 
    AnswerRe: Some basic Qs abt MFC,VC++,SDK.... Pin
    CPallini21-Jan-07 2:02
    mveCPallini21-Jan-07 2:02 
    AnswerRe: Some basic Qs abt MFC,VC++,SDK.... Pin
    Gary R. Wheeler21-Jan-07 2:59
    Gary R. Wheeler21-Jan-07 2:59 
    AnswerRe: Some basic Qs abt MFC,VC++,SDK.... Pin
    Christian Graus21-Jan-07 9:36
    protectorChristian Graus21-Jan-07 9:36 
    QuestionHow to convert value to string in c? Pin
    Agbaria Ahmad21-Jan-07 1:00
    Agbaria Ahmad21-Jan-07 1:00 
    AnswerRe: How to convert value to string in c? Pin
    Dominik Reichl21-Jan-07 1:21
    Dominik Reichl21-Jan-07 1:21 
    QuestionHow to get SQL stored procedure output / return code Pin
    neilsolent20-Jan-07 21:59
    neilsolent20-Jan-07 21:59 
    QuestionHow to SetEvenRowStyle in truedbgrid control in run time? Pin
    liur1720-Jan-07 19:38
    liur1720-Jan-07 19:38 
    QuestionCtrl+Double click message Pin
    Max++20-Jan-07 14:39
    Max++20-Jan-07 14:39 
    AnswerRe: Ctrl+Double click message Pin
    PJ Arends20-Jan-07 19:22
    professionalPJ Arends20-Jan-07 19:22 
    AnswerRe: Ctrl+Double click message Pin
    prasad_som21-Jan-07 1:36
    prasad_som21-Jan-07 1:36 
    AnswerRe: Ctrl+Double click message Pin
    prasad_som21-Jan-07 1:32
    prasad_som21-Jan-07 1:32 
    QuestionASF Writer Directshow Filter Pin
    gigo2k620-Jan-07 12:29
    gigo2k620-Jan-07 12:29 
    QuestionLNK2005 and template class Pin
    Nick Alexeev20-Jan-07 12:27
    professionalNick Alexeev20-Jan-07 12:27 
    AnswerRe: LNK2005 and template class Pin
    Michael Dunn20-Jan-07 15:20
    sitebuilderMichael Dunn20-Jan-07 15:20 
    GeneralRe: LNK2005 and template class Pin
    Sceptic Mole21-Jan-07 0:03
    Sceptic Mole21-Jan-07 0:03 
    QuestionRe: LNK2005 and template class Pin
    Nick Alexeev21-Jan-07 19:44
    professionalNick Alexeev21-Jan-07 19:44 

    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.