Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

negative number in binary

 
Tony Xu
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, can anybody help? Thanks in advance.
what i know is to get the binary format of positive numbers, like 25:
25 = 1 + 8 + 16, that is
0000 0001 ///this is one
0000 1000 //this is eight
0001 0000 //this is sixteen
---------
0001 1001 //this is what i want: twenty five in byte type
00000000 00000000 00000000 0001 1001 //is 25 in int type
while, i have no idea how to get -25. as i know it would be different in byte than in int. Is the difference is to add all "one" before the -25 in byte format, which i don't know how to get?
 
Manish Hatwalne
Ranch Hand
Posts: 2591
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tony,
I had replied to Jody's similar post earlier, have a look at that thread and see if it is of any help.
Here is the thread
Don't know if it (my reply) makes any sense.
Regards,
- Manish
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic