FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java-Programs/Bit_Manipulation/BitShift.java at master · githubanalyzeruser/Java-Programs · GitHub
githubanalyzeruser
/
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
/
BitShift.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
40 lines (32 loc) · 1.78 KB
Breadcrumbs
Java-Programs
/
Bit_Manipulation
/
BitShift.java
Copy path
File metadata and controls
40 lines (32 loc) · 1.78 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
package
Bit_Manipulation
;
import
java
.
util
.
Scanner
;
class
BitShift
{
public
static
void
main
(
String
[]
args
){
Scanner
sc
=
new
Scanner
(
System
.
in
);
System
.
out
.
print
(
"Enter a decimal number: "
);
int
x
=
sc
.
nextInt
();
int
a
=
15
;
//0000 1111
int
b
=
22
;
//0001 0101
int
c
=
24
;
System
.
out
.
println
(
"Your numbers "
+
x
+
" binary value: "
+
Integer
.
toBinaryString
(
x
));
System
.
out
.
println
(
a
+
" Binary value: "
+
Integer
.
toBinaryString
(
a
));
System
.
out
.
println
(
b
+
" Binary value: "
+
Integer
.
toBinaryString
(
b
));
System
.
out
.
println
(
c
+
" Binary value: "
+
Integer
.
toBinaryString
(
c
));
System
.
out
.
println
(
"------------------------------------------"
);
int
lshift
=
a
<<
1
;
System
.
out
.
println
(
"left shift Operation : "
+
lshift
+
"
\t
\t
Binary value: "
+
Integer
.
toBinaryString
(
lshift
));
int
rshift
=
b
>>
1
;
System
.
out
.
println
(
"Right shift Operation : "
+
rshift
+
"
\t
\t
Binary value: "
+
Integer
.
toBinaryString
(
rshift
));
int
zshift
=
c
>>>
1
;
System
.
out
.
println
(
"Right shift zero fill Operation : "
+
zshift
+
"
\t
Binary value: "
+
Integer
.
toBinaryString
(
zshift
));
System
.
out
.
println
(
"------------------------------------------"
);
int
l
=
x
<<
1
;
System
.
out
.
println
(
"left shift Operation on your number: "
+
l
+
"
\t
\t
Binary value: "
+
Integer
.
toBinaryString
(
l
));
int
r
=
x
>>
1
;
System
.
out
.
println
(
"Right shift Operation on your number: "
+
r
+
"
\t
\t
Binary value: "
+
Integer
.
toBinaryString
(
r
));
int
rz
=
x
>>>
1
;
System
.
out
.
println
(
"Right shift zero fill Operation on your number: "
+
rz
+
"
\t
\t
Binary value: "
+
Integer
.
toBinaryString
(
rz
));
System
.
out
.
println
(
"-------------------------------------------"
);
sc
.
close
();
}
}
Back
|
FazBrowse Home
|
New Git URL