1.11M Members

Binary-to-decimal

 
0
 

How do you convert a decimal to binary and vice versa? using netbeans ide

 
1
 

Integer.toBinaryString(int) in case you don't have to implement the algorithm yourself.

Also note that if you write e.g. int x = 5; the 5 is actually stored in binary.
System.out.println(x); prints 5 because the binary value in x is converted to base 10 for display.

 
1
 

this may help
http://www.roseindia.net/java/java-conversion/BinaryToDecima.shtml

... or not. That's a really tortuous and horrible way to see if a string just contains '0' and '1' (if you can work it out at all, given the lousy coding standards). There may be some good stuff on RoseIndia, but most of it,, like this one, seems to be rubbish. I certainly would not use it as a reference source.

 
0
 

don't like to roseindia, it's the worst excuse for a programming help website out there.
Or if you link to them, link to them as an example how not to do something.

mvmalderen has the correct answer, unless of course you are receiving a different binary representation from the one that Java is expecting (little endian vs. big endian, etc.).

 
0
 

another side-point: the IDE you use is not relevant.

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: