what means the token | [message #93171] |
Mon, 08 September 2003 09:02  |
Eclipse User |
|
|
|
Originally posted by: Gsoellhofer_Guenther.t-online.at
Hi there
I am new in programming swt could someone tell what this means!
int openOptions = MQC.MQOO_INPUT_SHARED | MQC.MQOO_INQUIRE |
MQC.MQOO_BROWSE;
if (schreibend)
openOptions |= MQC.MQOO_OUTPUT | MQC.MQOO_SET_IDENTITY_CONTEXT;
especially the |= sign
thanks
|
|
|
|
Re: what means the token | [message #93275 is a reply to message #93171] |
Mon, 08 September 2003 12:27  |
Eclipse User |
|
|
|
> Hi there
>
> I am new in programming swt could someone tell what this means!
>
> int openOptions = MQC.MQOO_INPUT_SHARED | MQC.MQOO_INQUIRE |
> MQC.MQOO_BROWSE;
> if (schreibend)
> openOptions |= MQC.MQOO_OUTPUT | MQC.MQOO_SET_IDENTITY_CONTEXT;
>
> especially the |= sign
These Constants have an integer value. The integer value has an
binary expression within the computer.
Count : bits
0=0000
1=0001
2=0010
3=0011
4=0100
....
8=1000
.....
15=1111
In computer sience there are 3 very important bit operations.
AND ( & ):
Bitwise combine:
0 & 0=0 , 0 & 1=0 , 1 & 0=0 , 1 & 1=1
-> 01011 & 10011 = 00011
OR ( | ):
Bitwise combine:
0 | 0 = 0, 0 | 1=1, 1 | 0=1, 1|1=1
-> 01011 | 10011 = 11011
XOR ( ^ ):
Bitwise combine:
0 | 0 = 0, 0 | 1 = 1, 1 | 0 = 1, 1|1=0
(a ^ b ) ^ b = a (mainly used by
encryption and graphic algorithms)
-> 01011 ^ 10011 = 11000
11000 ^ 10011 = 01011
&= , |=, ^=
Same like +=, -=, *=, /=
its a lazy operator - a short cut
a = a + b is the same like a += b;
so a |= b means: a = a | b
its like ++ and --
a++ is the same like a=a+1
(but note a++ and ++a is a diffrents
when you use it on parameters)
a=5;
foo(a++); //is foo(5)
a=5;
foo(++a); //if foo(6)
(differs in what value to take as
parameter, a before increment or
a after increment.)
&&, ||
are the logical equalents.
boolean && boolean = boolean
The boolean type only has two states
true or false. So take the bitwise
combination and use it on the boolean value
true && false = fase, true && true = true
-> true = 1 and false = 0
same with ||
I hope this explains it somehow ;)
Martin (Kersten)
|
|
|
Powered by
FUDForum. Page generated in 0.08002 seconds