FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java-Programs/Bit_Manipulation/BitOperations.java at master · Gawsan/Java-Programs · GitHub
Gawsan
/
Java-Programs
Public
forked from
divScorp/Java-Programs
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Java-Programs
/
Bit_Manipulation
/
BitOperations.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
45 lines (40 loc) · 1.25 KB
Breadcrumbs
Java-Programs
/
Bit_Manipulation
/
BitOperations.java
Copy path
File metadata and controls
45 lines (40 loc) · 1.25 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package
Bit_Manipulation
;
class
BitOperations
{
public
static
void
main
(
String
[]
args
){
int
a
=
15
;
//0000 1111
int
b
=
21
;
//0001 0101
//AND Operation
/*
0000 1111
& 0001 0101
--------------
0000 0101
*/
int
f
=(
a
&(
a
-
1
));
System
.
out
.
println
(
"Power of 2 Operation : "
+
f
+
" Binary value: "
+
Integer
.
toBinaryString
(
f
));
int
and
=
a
&
b
;
System
.
out
.
println
(
"AND Operation : "
+
and
+
" Binary value: "
+
Integer
.
toBinaryString
(
and
));
//OR Operation
/*
0000 1111
| 0001 0101
--------------
0001 1111
*/
int
or
=
a
|
b
;
System
.
out
.
println
(
"OR Operation : "
+
or
+
" Binary value: "
+
Integer
.
toBinaryString
(
or
));
//XOR Operation
/*
0000 1111
& 0001 0101
--------------
0001 1010
*/
int
xor
=
a
^
b
;
System
.
out
.
println
(
"XOR Operation : "
+
xor
+
" Binary value: "
+
Integer
.
toBinaryString
(
xor
));
int
x
=
7
;
//NOT Operation
int
not
=~
x
;
System
.
out
.
println
(
"NOT Operation : "
+
not
+
" Binary value: "
+
Integer
.
toBinaryString
(
not
));
}
}
Back
|
FazBrowse Home
|
New Git URL