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 8495479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:35:07+00:00 2026-06-10T23:35:07+00:00

Two’s complement method – generates -(x + 1) . for example when JavaScript encounters

  • 0

Two’s complement method – generates -(x + 1).

for example when JavaScript encounters the Tilde he uses this method:

~5 = -(5+1) = -6.

Fine – lets go deeper.

Now lets talk about the Two’s complement method.

5        = 0000 0101
Flip     = 1111 1010
add one  = 1111 1011

so 1111 1011 is -5.

how ?

again : flip :

0000 0100 

add one :

0000 0101

And so it was -5.

So how does this settle with ~5=-6 ?

where this -6 came from ?

  • 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-10T23:35:09+00:00Added an answer on June 10, 2026 at 11:35 pm

    First of all, you need to realize that ~ is the bitwise flip operator, which is not the same as the negate operator -. ~ does only the bitwise flipping, but the negate operator - does bitwise flipping and add one (for integers).

    As you’ve explained, if yo want to go from a postive number n to -n using the two complement method you bitwise flip/not n and add 1. ~n is just the bit-wise not meaning that ~n=-n-1.

    For instance:

    5               = 0000 0101
    Flipped (~5)    = 1111 1010
    

    So, which number does 1111 1010 represent? Since the first digit is a 1 we know it’s a negative value. To find which value, do

    -(flip(1111 1010) + 1) =
    -(0000 0101 + 1)
    -(0000 0110) =
    -6
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Two related questions. First: does this repro for you or is it something local
Two days ago I wrote this question: How can I retrieve an object on
Two points -- first, the example is in Fortran, but I think it should
Two things, first this is my first question in this forum and I do
Two part question: After calling the Mixpanel api I am returned something like this
Two different slider controls fires this function below, their names are seektomediaposition and seektomediaposition2.
Two questions. Is there a way for us to query by substring/contains method or
two errors suddenly fired in this piece of code - duplicate interface declaration for
Two trees are said to be identical if they contain same set of elements
Two questions only: I have a website including a section of Blog in wordpress.

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.