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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:06:32+00:00 2026-05-27T19:06:32+00:00

OK, so say I have a signed char with value -103: char s_char =

  • 0

OK, so say I have a signed char with value -103:

char s_char = -103;

How does the computer store this char in bits? Is the first bit 0 because the char is negative? If so, would the computer store the char as 01100101, because 1100101 (base 2) in base 10 is 103?

And a second question: how can I access or test a single bit in the signed char? Would

s_char & (0x80 >> pos)

give me the value of the bit at position pos counting from the left?

  • 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-27T19:06:33+00:00Added an answer on May 27, 2026 at 7:06 pm

    Signed values are usually stored using Two’s Complement. http://en.wikipedia.org/wiki/Two%27s_complement

    This essentially provides a signed bit which determines whether or not the number stored is negative or positive. If you’re using an 8-bit int for example, the range of possible signed numbers is -128 to 127. This breaks down to a series of 8 bits, for example, where the left-most bit represents a value of -128. The bits following ‘hold’ half the value as the bit to left, but are positive instead. An 8-bit number in binary form would look like this:

    0    0    0    0    0    0    0    0
    -128 64   32   16   8    4    2    1
    

    Since a char is an integer type, it would be stored in the same way as a regular int would be. A char with the value of -103 would break down to something like this:

    1    0    0    1    1    0    0    1
    -128 64   32   16   8    4    2    1
    

    If you want to test a single bit, you could use a mask. For example, if you wanted to test if the left most bit was set, you could do something like this:

    s_char & (0x80)
    

    This return true if the left-most bit was set to 1 in s_char, regardless of the other bits. I hope that helps!

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

Sidebar

Related Questions

Say I have the classic 4-byte signed integer, and I want something like print
Lets say have this immutable record type: public class Record { public Record(int x,
Let's say I have this: float i = 1.5 in binary, this float is
I have an app which is available in app store and was signed with
Say I have these two variables: size_t value; size_t size; And I want to
Note that when I say client, I mean businesses or organizations that have signed
Let's say have something like: SELECT energy_produced, energy_consumed, timestamp1 AS timestamp FROM ( SELECT
Say we have the following method: private MyObject foo = new MyObject(); // and
Say I have the following file structure: app/ app.py controllers/ __init__.py project.py plugin.py If
Say you have an application divided into 3-tiers: GUI, business logic, and data access.

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.