Jump to content
  • Advertisement
Sign in to follow this  
Fernand

Convert Binary to Decimal in Java

This topic is 4889 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

HI, How can I make this conversion with negative binary numbers?? The method Integer.parseInt(bin,2) don´t function to negative values?? Thanks, Fernand

Share this post


Link to post
Share on other sites
Advertisement
If your number is greater than 2147483647 (231-1), then substract 4294967296(232) from it.

Share this post


Link to post
Share on other sites
Java ints are signed, so I don't think that will be of use :s

How exactly are you expecting a 'negative binary number' to be represented? With an actual negative sign on the front? Or in 2s complement?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!