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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:17:01+00:00 2026-06-05T09:17:01+00:00

Suppose that there are two integers( int x, y; ). x is negative and

  • 0

Suppose that there are two integers(int x, y;).
x is negative and y = 0x80000000.

Why does (x - y) not overflow while x + (-y) does?
Doesn’t the computer do subtraction by addition?

  • 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-05T09:17:02+00:00Added an answer on June 5, 2026 at 9:17 am

    To answer your first question, 0x80000000 (-2,147,483,648) represents minimum 32-bit value for signed integers. 2,147,483,647 is the maximum value. The magnitude of the maximum value is one less than the magnitude of the minimum value when stored using Two’s Complement. Taking (-y) alone cannot be represented as it exceeds the maximum value (by 1). The final integer value of (x-y) is in range (given that x is negative) and can be represented by a 32-bit integer.

    To answer your second question, subtraction is achieved by converting the number to be subtracted into its additive inverse. Given the potential for overflow in this situation, your compiler can get the correct result for (x-y) by doing -((-x)+y). However, this is pure speculation (it is the only way I can think of to do it safely).

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

Sidebar

Related Questions

Suppose there are given two integers, a and b, and we know that a>b.
Suppose that there're two types of packet in the chatting server. Those two packets
Suppose i have one folder and inside that another two files are there .
In Java, suppose I have a method that takes in two lists of integers,
Let's suppose I have two grammars (and that there is a Lexer defined somewhere),
Suppose there's a top-secret list (inherits its permissions from its parent) that contains records
Suppose that I have those three files: a.h //a.h header #include <stdio.h> int int_variable;
Suppose we've got two integer and character variables: int adad=12345; char character; Assuming we're
Suppose that the function void foo(int n, double x[]) sorts the n-vector x ,
Suppose that I have two classes, first a class without any properties, fields or

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.