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

  • Home
  • SEARCH
  • 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 9135803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:52:14+00:00 2026-06-17T08:52:14+00:00

When I give to a variable such value: e = 17|-15; , I get

  • 0

When I give to a variable such value: e = 17|-15; , I get -15 as an answer after compiling.I can’t understand what arithmetic c++ uses. How does it perform a bit-wise OR operation on negative decimals?

  • 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-17T08:52:15+00:00Added an answer on June 17, 2026 at 8:52 am

    It’s just doing the operation on the binary representations of your numbers. In your case, that appears to be two’s complement.

     17 -> 00010001
    -15 -> 11110001
    

    As you can see, the bitwise OR of those two numbers is still -15.

    In your comments above, you indicated that you tried this with the two’s complement representations, but you must have done something wrong. Here’s the step by step:

     15 ->  00001111      // 15 decimal is 00001111 binary
    -15 -> ~00001111 + 1  // negation in two's complement is equvalent to ~x + 1
    -15 ->  11110000 + 1  // do the complement
    -15 ->  11110001      // add the 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a variable which contains a value such as -9 i have 21
Apparently, Ruby can make a code block returning an instance variable's value with a
I am having problems creating a simple PHP script. The $_GET[give] variable is always
In my page I need to give my current variable as parameter to the
Give an Image component, how can I tell the size [width and height] of
Is it possible to detect when the value of a variable has changed using
I'm trying to give OrientDB a go on Windows, but I can't even seem
Possible Duplicate: How does an underscore in front of a variable in a cocoa
I remember somewhere seeing such a notation for formally defining a variable: variable_name: type
Is it possible to use the command ceil on a time format variable such

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.