bit computer in java and i have run into a weird problem. i have a binary number stored as an integer and i needed to convert it to a string but when i do the Integer.toString()
returns 9 when i gave it 00000011 but it should have returned 3 right?
here's the function i was making
static int binToInt(int bin)
{
String binary = Integer.toString(bin);
return Integer.parseInt(binary, 2);
}
Can someone explain?
i have been trying for over an hour to find a solution. either i find a page with something else or a tutorial of how to use Integer.toString()