Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Conversion of negative binary number to decimal number

 
nagajyothi Avusingi
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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'.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic