I was trying to convert a simple Integer to a binary string, using the static Integer.toBinaryString(int arg0) method.
When i run the following code, a String of length 32 is outputted, while a String of length 8 suffise.
Java Code:
public class Test{
public static void main(String[] args){
// output= 11111111111111111111111111111111
// output= 11111111111111111111111110010000
}
}
When manually converting the binary string back to an integer, the number simply doesn't match. When converting 255 to binary, the output should be:
Is this method returning a wrong result (i doubt that), or am i just wrong with my calculation or interpretation?
Thanx,
UnrealEd