| Author |
bitwise manipulators
|
Ben Hultin
Ranch Hand
Joined: Aug 17, 2009
Posts: 135
|
|
I am working on a program that requires the use of bitwise manipulators. The problem is that while I can find a lot of articles explaining it lengthy paragraphs, I have yet to find one containing syntax on using it.
The setup I need to create is:
I am just not sure how to properly use manipulators. If you could show me syntax that would be fantastic or better yet show me to an article that contains actual syntax.
I appreciate the help
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12907
|
|
The operators work just like any other operators such as +, -, * and /.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32599
|
|
|
Long time since I wrote about bitwise operators. Try here.
|
 |
Rajeev Trikha
Ranch Hand
Joined: Jan 29, 2010
Posts: 85
|
|
Play with this code to clarify your views.
byte number = 0;
if (number > 0) {
System.out.println("Pre: " + number);
number >>= 1;
System.out.println("Post: " + number);
} else if (number == 0) {
System.out.println("Pre: " + number);
number = (byte) ~number;
System.out.println("Post: " + number);
} else if (number < 0) {
System.out.println("Pre: " + number);
number <<= 1;
System.out.println("Post: " + number);
}
|
Rajeev Trikha (SCJP 6)
|
 |
 |
|
|
subject: bitwise manipulators
|
|
|