Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » what means the token |
what means the token | [message #93171] Mon, 08 September 2003 09:02 Go to next message
Eclipse UserFriend
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 #93199 is a reply to message #93171] Mon, 08 September 2003 09:47 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: faust.acm.org

In the non-boolean world its a bitwise OR. |= is an operation an assignment
together. For example:

int x= 1; // 0001
int y= 4; // 0100
int z= 7; //. 0111

int bitwiseOr= x | y | z;
// value of bitwiseOr is 7

int bitwiseAssignOr= 1;
bitwiseAssignOr |= y;
// value is now 5

Or other assignment operations like:
int x= 2;
x += 4;
// value of x is now 6

Pick up any Java book worth its salt for further explanation.


Randy

"G
Re: what means the token | [message #93275 is a reply to message #93171] Mon, 08 September 2003 12:27 Go to previous message
Eclipse UserFriend
> 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)
Previous Topic:Syntax Color problems - universal
Next Topic:Sample plug-ins?
Goto Forum:
  


Current Time: Wed May 07 15:19:18 EDT 2025

Powered by FUDForum. Page generated in 0.08002 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top