This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How Do I Type the Symbol for the Or Operator

 
Benjamin Chau
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question: Can someone tell me how to type the symbol for the Or operator? Usually it's two vertical lines side by side (kinda like this: ll) but I don't know how to do that on the computer keyboard, unless I use the Shift, Alt, Function, and/or Ctrl keys, etc.

Can I just use the word "or" instead of the symbol ??? Also, is the Boolean symbol for Or the same as the arithmetic symbol for Or ???
 
Campbell Ritchie
Sheriff
Pie
Posts: 48968
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Varies from country to country. On my keyboard it is at the bottom left, shift-\
 
Benjamin Chau
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
TOO COOL! Thanks Campbell!
 
Henry Wong
author
Marshal
Pie
Posts: 21123
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, is the Boolean symbol for Or the same as the arithmetic symbol for Or ???


No. The logical OR is a double vertical, while the arithmetic OR is a single vertical.

And BTW, on my keyboard, it is also "shift-backslash", but mine is located right above the return key.

Henry
 
Benjamin Chau
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry,

Will you check my code in the other topic I submitted "Program: Change Due/Tendered"? I know what you said in response to it - I'm still working on compile issues. Specifically, will you check my code within the do...while statement to see if my use of the single vertical line | for the Or operator fits this situation? We just talked about that in this post thread and this part of the program in question deals with it. But I'm having trouble determining whether this case is logical or arithmetic (I'm leaning towards arithmetic, as reflected in my code). Thanks a bunch...

Benjamin
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, this character is often called a "pipe."
 
Rob Spoor
Sheriff
Pie
Posts: 20531
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Henry Wong:
No. The logical OR is a double vertical, while the arithmetic OR is a single vertical.

Logical OR can be both | and || - the first one always evaluates the right operand, the second only if the first operand results in false.
 
J. Noah
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I actually don't think that's correct - one pipe is for bitwise inclusive OR. http://java.sun.com/docs/books/tutorial/java/nutsandbolts/operators.html
 
Campbell Ritchie
Sheriff
Pie
Posts: 48968
60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the | with booleans as an inclusive OR.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34410
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Campbell Ritchie:
Varies from country to country. On my keyboard it is at the bottom left, shift-\

It also varies within a country. I'm in the United States and my work keyboard and home keyboard have the key in different places. Which is annoying because you have to remember where you are before touch typing!

General convention is either above/below/next to the "enter" key so at least there are only two places to look.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The tutorial seems a "bit" lacking in this respect.

For clarification, see JLS - 15.22.2 Boolean Logical Operators &, ^, and |...
When both operands of a &, ^, or | operator are of type boolean or Boolean, then the type of the bitwise operator expression is boolean.

As Rob pointed out, the difference is that the || is conditional, in that the right operand is evaluated only if the left operand evaluates to false. See JLS - 15.24 Conditional-Or Operator ||.

(In this context, it seems as if the tutorial might be treating a boolean as a single bit, which I think is a mistake, because the size of a Java boolean is not defined.)
[ November 16, 2008: Message edited by: marc weber ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic