Account name:
Password
(OpenID?)
(Forgot it?)
Remember Me
You're viewing
grauwulf
's journal
Create a Dreamwidth Account
Learn More
Interest
Region
Site and Account
FAQ
Email
Reload page in style:
site
light
grauwulf
test
test
Nov
.
11th
,
2002
11:29 pm
grauwulf
public class testApp { public static void main(String[] args) { System.out.println("----- in the main method. -----"); // These are the values passed from the prompt int[] bwTest = new int[args.length]; for (int i = 0; i<args.length; i++) { System.out.println("args["+ i +"] = "+ args[i]); bwTest[i] = Integer.parseInt(args[i]); } // this method does some basic bitwise manipulation. bitWiseTest(bwTest[0], bwTest[1]); // this method does some basic bitwise manipulation. testBitLoop(bwTest[2], bwTest[3]); // last test of 11/11/02 // return the Binary value of the args[].length String binaryValue = testBinaryValue(args.length); System.out.println("the binary value of the args array length is:"); System.out.println(binaryValue); System.out.println("----- GoodBye -----"); } private static void bitWiseTest(int a1, int a2) { System.out.println("----- in the bitWiseTest method -----"); int c = a1 & a2; System.out.println("result & : " + Integer.toBinaryString(c) + " = " + c); c = a1 | a2; System.out.println("result | : " + Integer.toBinaryString(c) + " = " + c); c = a1 ^ a2; System.out.println("result ^ : " + Integer.toBinaryString(c) + " = " + c); System.out.println("Binary of : " + a1 + " = " + Integer.toBinaryString(a1)); System.out.println("Binary of : " + a2 + " = " + Integer.toBinaryString(a2)); System.out.println("complement of : " + a1 + " = " + Integer.toBinaryString(~a1)); System.out.println("complement of : " + a2 + " = " + Integer.toBinaryString(~a2)); a2 <<= 1; System.out.println("Shift left 1 : " + a2 + " = " + Integer.toBinaryString(~a2)); a2 >>= 1; System.out.println("shift right 2 : " + a2 + " = " + Integer.toBinaryString(~a2)); } private static void testBitLoop(int bitStart, int LoopKill) { System.out.println("----- in the testBitLoop method -----"); int bitStop = bitStart + LoopKill; System.out.println("bitStart = "+ bitStart); System.out.println("bitStop = "+ LoopKill); while(bitStart < bitStop) { System.out.println("bitLoop Value = "+ bitStart +" Binary Value= "+ Integer.toBinaryString(bitStart)); ++bitStart; } } private static String testBinaryValue(int toConvert) { System.out.println("----- in the testBinaryValue method -----"); String converted = Integer.toBinaryString(toConvert); System.out.println(Integer.toBinaryString(toConvert)); return converted; } }
Flat
|
Top-Level Comments Only
(no subject)
Date:
2002-11-11 09:52 pm (UTC)
From:
grauwulf.livejournal.com
is that a bad thing?
what did you think of the little bit-flipper there?
Re:
Date:
2002-11-12 05:45 am (UTC)
From:
irenes.livejournal.com
It looks nice ;)
I don't really get bit manipulation either... boggles my mind as well ... since I've never needed to use it either.
3 comments
Reply
Flat
|
Top-Level Comments Only
Profile
grauwulf
Navigation
Recent Entries
Archive
Reading
Tags
Memories
Profile
June
2020
S
M
T
W
T
F
S
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
Most Popular Tags
blutengel - du tanzt
-
1 use
fencingblog
-
16 uses
violent fems
-
1 use
Page Summary
grauwulf.livejournal.com
-
(no subject)
Style Credit
Base style:
Fluid Measure
by
branchandroot
Theme:
Pigeon Blue
by
dancing_serpent
Expand Cut Tags
No cut tags
Page generated Feb. 3rd, 2026 10:06 pm
Powered by
Dreamwidth Studios
(no subject)
Date: 2002-11-11 09:52 pm (UTC)what did you think of the little bit-flipper there?
Re:
Date: 2002-11-12 05:45 am (UTC)I don't really get bit manipulation either... boggles my mind as well ... since I've never needed to use it either.