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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T02:33:54+00:00 2026-05-19T02:33:54+00:00

suppose i have a variable int a=512 Now when i apply ~a which means

  • 0

suppose i have a variable

int a=512

Now when i apply ~a which means one’s complement in c.How i am getting -513 as the output.

int is minimum 16 bits in size and binary equivalent of 512 is

0000 0010 0000 0000 And now when you do its one’s complement it becomes

1111 1101 1111 1111. Now could someone tell me why the output is -513.

Can I now Hope that guys in this forum understood my question.

  • 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-05-19T02:33:55+00:00Added an answer on May 19, 2026 at 2:33 am

    Negative numbers are often represented as two’s complement, which is why it is interpreted the way it is.

    Assuming int is 16-bit, you will have the bitpattern 1111 1101 1111 1111. Since the top-most bit is set, the number is negative. To convert to decimal, according to the rules for two’s complement, the number is first bitwise-inverted. This brings back your 512. Then one is added, which gives 513. And since the number was negative, we get -513.

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

Sidebar

Related Questions

Suppose we have a variable k which is equal 7: int k=7; int t=&k;
Suppose I have a variable of type Int = 08, how can I convert
In Java, suppose I have a String variable S, and I want to search
Suppose I have a class module clsMyClass with an object as a member variable.
Suppose that I have those three files: a.h //a.h header #include <stdio.h> int int_variable;
Suppose I have a variable counter, and there are several threads accessing and setting
Suppose I have a static variable declared inside a function in C. If I
I have a std::set which is of type point struct point { int x;
Suppose we have an array say: int arr[1000]; and I have a function that
Suppose I would like to extend class C , getting SubC . Now I

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.