Image

Imagegrauwulf wrote in Imagejava_dev 😀enthralled

Listens: Metallica : Attitude

bit manipulation....

Okay as I just found the group allow me to introduce myself, then on to the fun stuff...

nethead (read Programmer/Analyst I) two years active java programming, mostly servlets and the such (cics|oracle->java->(xml/xslt)|(jsp)) nth teir stuff. weblogic is the app layer of choice with sun iplanet running prez. dev environ of choice is textpad 4.5.0 (although I keep a copy of visual cafe ee for those really convoluted cr-app-taculars). I'll be the first to admit i'd rather be doing design but I like to burry my self in the code form time to time too. anyway

Now to the skinny: getting ready to take 310-025 SCJP. while brushing up on my stand alone coding I ran accross a study note which mentioned that I should really know my bit-flips for the test... so I have two questions (1) how deep should I go in to bitwise manipulations for the test? (2) could someone drop me a practical app for the use of these priniples?

I'm sure this sounds really lame, this is just stuff I never really mess with and I want to make sure I have all of my bases covered.

Below is a quick little class I just wrote to run myself back through the basics. all critisim is welcome.
-----

/**
* $> java testApp 1 2 3 4
*/
System.out.println("----- in the main method. -----");

// These are the values passed from the prompt
for (int i = 0; i
[Error: Irreparable invalid markup ('<args.length;>') in entry. Owner must fix manually. Raw contents below.]

Okay as I just found the group allow me to introduce myself, then on to the fun stuff...

nethead (read Programmer/Analyst I) two years active java programming, mostly servlets and the such (cics|oracle->java->(xml/xslt)|(jsp)) nth teir stuff. weblogic is the app layer of choice with sun iplanet running prez. dev environ of choice is textpad 4.5.0 (although I keep a copy of visual cafe ee for those really convoluted cr-app-taculars). I'll be the first to admit i'd rather be doing design but I like to burry my self in the code form time to time too. anyway

Now to the skinny: getting ready to take 310-025 SCJP. while brushing up on my stand alone coding I ran accross a study note which mentioned that I should really know my bit-flips for the test... so I have two questions (1) how deep should I go in to bitwise manipulations for the test? (2) could someone drop me a practical app for the use of these priniples?

I'm sure this sounds really lame, this is just stuff I never really mess with and I want to make sure I have all of my bases covered.

Below is a quick little class I just wrote to run myself back through the basics. all critisim is welcome.
-----
<lj-cut text="Check out this little testApp class">
/**
* $> java testApp 1 2 3 4
*/
System.out.println("----- in the main method. -----");

// These are the values passed from the prompt
for (int i = 0; i<args.length; i++) {
System.out.println("args["+ i +"] = "+ args[i]);
}

// Converts String Objects into their Integer CounterParts
// ints for the bitwise operation testing
int bwTest1 = Integer.parseInt(args[0]); // generic test bits.
int bwTest2 = Integer.parseInt(args[1]); // ""
int bwTest3 = Integer.parseInt(args[2]); // BitLoop Start count
int bwTest4 = Integer.parseInt(args[3]); // BitLoop Stop count

// this method does some basic bitwise manipulation.
bitWiseTest(bwTest1, bwTest2);

// this method does some basic bitwise manipulation.
testBitLoop(bwTest3, bwTest4);

// 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;
}
}
</lj-cut>
-----
Thanks!
-Mel