Confused by '&' oparator

This is a discussion on Confused by '&' oparator within the Windows Programming forums, part of the Platform Specific Boards category; Hi! What is the '&' oparator in this statement? cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2) * cxChar ...

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    790

    Confused by '&' oparator

    Hi!

    What is the '&' oparator in this statement?

    cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2) * cxChar / 2 ;

    "reference", "bitwise" or "address of" operator?

    I think it cant be "reference" and "address of" because it wasnt declared.

    But if it "bitwise" oparator, where is the second argument?
    Compiler MSVC++ 2013 with Code::Blocks.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    It's a bitwise and, and the second argument is 1.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,648
    It is bitwise and. That parenthesized expression can be expressed as: ((tm.tmPitchAndFamily & 1) ? 3 : 2).
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #4
    Registered User
    Join Date
    Dec 2007
    Posts
    790
    Thank you Matsp and Laserlight, i understand it now.

    What confused me was the missing parentheses inside (( tm.tmPitchAndFamily & 1) ? 3 : 2).

    Next time im gonna imagine it there if i see an expression like that.
    Compiler MSVC++ 2013 with Code::Blocks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Confused about Memory
    By gL_nEwB in forum C++ Programming
    Replies: 22
    Last Post: 06-20-2006, 07:32 PM
  2. Confused
    By jeev2005 in forum C Programming
    Replies: 5
    Last Post: 06-01-2006, 02:04 PM
  3. So Now Im getting confused?!?!?
    By zergdeath1 in forum C++ Programming
    Replies: 11
    Last Post: 03-06-2004, 04:41 PM
  4. confused.. in selecting my line of deapth
    By jawwadalam in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 05-04-2003, 01:21 PM
  5. Extern Question, really confused
    By SourceCode in forum C Programming
    Replies: 10
    Last Post: 03-26-2003, 10:11 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21