Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9284763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T18:59:03+00:00 2026-06-18T18:59:03+00:00

Why are this two methods using two different approaches while processing binary numbers? String

  • 0

Why are this two methods using two different approaches while processing binary numbers? String which represents negative binary number in Integer.parseInt(String s, 2) method should start with - character, but Integer.toBinaryString(int i) returns string with additional 1 ahead. So, this code

Integer.parseInt(Integer.toBinaryString(-1), 2);

throws java.lang.NumberFormatException. What is the reason of such behavior?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T18:59:05+00:00Added an answer on June 18, 2026 at 6:59 pm

    This is by design; Integer.toBinaryString

    Returns a string representation of the integer argument as an unsigned integer in base 2.

    (emphasis added).

    I.e., toBinaryString provides a way to format an integer as the common two’s complement representation, which is the way most processors actually store signed integers internally.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I use synchronize(this) in two methods and one calls the other, will I
Possible Duplicate: Why do this Ruby object have two to_s and inspect methods that
having this two classes I always have a doubt of which is the best
I have noticed two different approaches to writing out data to an XML file
The two posts below are great examples of different approaches of extracting data from
in one of my projects I'm using following two methods. 1. GetDoubleValue and 2.
An example: Using VS I can create MyControl which derives from UserControl, to this
I have been working on two different approaches to create a graphical canvas with
This small program tests the two approaches of computing the factorial - by iteration
I know that there at least two approaches to leverage the web.config file: using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.