Results 1 to 9 of 9

Thread: What does this line of code do?? (easy)

  1. #1

    Thread Starter
    Hyperactive Member Wak's Avatar
    Join Date
    Nov 2000
    Location
    Brisbane, Queensland
    Posts
    298

    What does this line of code do?? (easy)

    I'm not sure what this does, can anyone help?

    cxCaps and cxChar are both integers

    Code:
    cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2) * cxChar / 2;
    It's mostly '& 1 ? 3 : 2)' That I don't know the meaning of.

    Thanx
    Visual Basic 6.0 Enterprise
    Visual C++ 6.0 Professional

    Wak

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Where did you get this code. The absolutely same question was posted by abdul a while ago. Here is the link
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  3. #3

    Thread Starter
    Hyperactive Member Wak's Avatar
    Join Date
    Nov 2000
    Location
    Brisbane, Queensland
    Posts
    298

    lol... what a coincidence

    I got it from a bloke called Charles Petzold.

    Would

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

    Code:
    cxCaps = (tm.tmPitchAndFamily ? 3 : 2) * cxChar / 2;
    Do the same thing then?
    Visual Basic 6.0 Enterprise
    Visual C++ 6.0 Professional

    Wak

  4. #4

    Thread Starter
    Hyperactive Member Wak's Avatar
    Join Date
    Nov 2000
    Location
    Brisbane, Queensland
    Posts
    298
    Whoops, I just stared blankly into the screen for 1/2 an hour and it hit me.

    Code:
    cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2) * cxChar / 2;
    Is the same as

    Code:
    cxCaps = ((!tm.tmPitchAndFamily & 0) ? 3 : 2) * cxChar / 2;
    I'm not the best @ C++ yet, sorry
    Visual Basic 6.0 Enterprise
    Visual C++ 6.0 Professional

    Wak

  5. #5
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    hi

    Yes, I am reading the same book. Is it programming windows 95 or windows 98?
    Baaaaaaaaah

  6. #6

    Thread Starter
    Hyperactive Member Wak's Avatar
    Join Date
    Nov 2000
    Location
    Brisbane, Queensland
    Posts
    298

    Question hi

    I dunno, the title is Programming Windows 5th Edition by Charles Petzold
    Visual Basic 6.0 Enterprise
    Visual C++ 6.0 Professional

    Wak

  7. #7
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    The author is giving almost the same examples in his window s programming books.

    I am reading "Programming Windows 95"
    Baaaaaaaaah

  8. #8

    Thread Starter
    Hyperactive Member Wak's Avatar
    Join Date
    Nov 2000
    Location
    Brisbane, Queensland
    Posts
    298

    Talking grrrrr

    I've heard the term 'a lazy programmer is a good programmer ' used, but plz. That refers to programming only. Not book writing.
    Visual Basic 6.0 Enterprise
    Visual C++ 6.0 Professional

    Wak

  9. #9
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Does it matter?

    Ternary form is one of the easiest-confused operators - took me a while to learn it (I was still looking up which way round the true and false values went until about a month ago )
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width