# bit conversion

public class BinDec{
public static void main(String argv[]){
System.out.println(Integer.parseInt("11",2));
System.out.println(Integer.toString(64,2));
}
}
I ran above program from link
http://www.jchq.net/certkey/0503certkey.htm
got output like
3
1000000

I did not understand how I got this output.

LVL 7
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
In the first case you parse integer written as 11 in binary system.
11 in binary system is 3

In toString(64,2) case it  in fact says present number 64 in binary system
and that would be 1000000

So the output looks quite understandable

0
Sr. ConsultantCommented:
0
Author Commented:
>>>In the first case you parse integer written as 11 in binary system.
11 in binary system is 3

In toString(64,2) case it  in fact says present number 64 in binary system

why there is " " for 11 where as not present for 64.

0
Commented:
If you look in API on Integer class, you'll see
that Integer.parseInt takes (String, int) as arguments, therefore there are quotes signs in the
argument of that method  method  "11"

Integer.toString takes (int, int), therfore the arguments are ^4 and 2 - two numbers, not strings - no quotes
The second argument is the radix in both cases, therefore
Integer.toString(64,2) produces the String interpreting integer 64 in binary mode, which would be 1000000
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.