• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

negative number in binary

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic