|
-
Jul 11th, 2001, 09:57 PM
#1
Thread Starter
PowerPoster
what are these characters?
I did not understand the following line:
Code:
cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2) * cxChar / 2;
which value does cxCaps get? And what are the "?" and ":" symbols used for?
-
Jul 12th, 2001, 05:31 AM
#2
Frenzied Member
The ? and : are the C++ only ternary operator. It means that if the expression tm.tmPitchandFamily & 1 is true then 3 is multiplied by cxChar else 2.
-
Jul 12th, 2001, 08:09 AM
#3
Thread Starter
PowerPoster
thanks
but 1 is not a boolean expression. How can it be true of false?
-
Jul 12th, 2001, 08:12 AM
#4
Monday Morning Lunatic
x & 1 checks bit patterns, and if it's found, returns true. Plus most integers can be converted to bool (0 = false, everything else = true).
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
-
Jul 12th, 2001, 08:13 AM
#5
Frenzied Member
0 is false in C++ and everyother value is true. That is why
while(1) is an infinite loop. But in this case it is not just 1 it is
tm.tmPitchAndFamily & 1
-
Jul 12th, 2001, 08:14 AM
#6
Frenzied Member
Whoops!! parksie is faster
-
Jul 12th, 2001, 08:24 PM
#7
Hope im not sounding stupid hear, but...
Doesnt "x & 1" perform a binary AND on x with 0x0001?
Z.
-
Jul 13th, 2001, 03:05 AM
#8
Frenzied Member
Yes, like Parksie said about the bit patterns, & is a bitwise operator.
& - bitwise AND
&& - boolean AND
Harry.
"From one thing, know ten thousand things."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|