aspose file tools*
The moose likes Beginning Java and the fly likes Conversion of negative binary number to decimal number Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Conversion of negative binary number to decimal number" Watch "Conversion of negative binary number to decimal number" New topic
Author

Conversion of negative binary number to decimal number

nagajyothi Avusingi
Greenhorn

Joined: May 06, 2004
Posts: 1
if we have a byte value EX: 11111111 where 1 in first digit place shows that its negative number, how to get back the decimal number which will be negative.
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

You can convert it to an int, and then convert this into a byte:

The casting in the second line is needed, to avoid the compilerwarning 'possible loss of precision'.


http://home.arcor.de/hirnstrom/bewerbung
 
Don't get me started about those stupid light bulbs.
 
subject: Conversion of negative binary number to decimal number