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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:27:00+00:00 2026-05-12T16:27:00+00:00

I used to think that each memory location contains 8, 16, 32 or 64

  • 0

I used to think that each memory location contains 8, 16, 32 or 64 bits. So 0101 would be stored in an 8 bit machine as 00000101 (sign extended if it was negative). This was all fine and dandy until I wrote a program in java out of curiosity to find out some more inner workings of this system.

The method in question looks like this:

public void printBinaryRep(File f){
        try{
            FileInputStream inputStream = new FileInputStream(f);
            int next = 0;
            byte b = 0;
            while((next = inputStream.read()) != -1){
                b = (byte)next;
                System.out.println((char)next + " : "+Integer.toBinaryString(next));
            }
            inputStream.close();
        }
        catch(Exception e){System.out.println(e);}
 }

I got this output from a file that says Hello World

H : 1001000
e : 1100101
l : 1101100
l : 1101100
o : 1101111
  : 100000
W : 1010111
o : 1101111
r : 1110010
l : 1101100
d : 1100100

All of it looks fine except for the space. It has 6 bits instead of 8.
I’m now wondering how all of that information is stored in memory. If all of it was stored in 8 bit chunks, like

Hello: 10010001100101110110011011001101111

Then you can simply look at each 8 bit chunk and figure out what number it’s representing (and then what ASCII code it’s referring to).
How does it work when a different sized character (like the 6 bit space and the 4 bit /n ) is stored along with them?? Then wouldn’t storing a small number in a large bit space waste a lot of bits?

I think I have some of the fundamental understanding wrong (or maybe the program’s wrong somewhere…). Sorry if the question sounds strange or too un-necessarily in-depth. I just want to know. I’ve done some googling, but it didn’t come up with anything relevent. If you can let me know where I’ve gone wrong or point me in the right direction, I’d greatly appreciate it.
Thanks!

  • 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-12T16:27:00+00:00Added an answer on May 12, 2026 at 4:27 pm

    You’ll be better off experimenting in C and/or assembly, rather than Java. Those languages are lower-level and expose the address space directly.

    I used to think that each memory
    location contains 8, 16, 32 or 64
    bits. So 0101 would be stored in an 8
    bit machine as 00000101 (sign extended
    if it was negative). This was all fine
    and dandy until I wrote a program in
    java out of curiosity to find out some
    more inner workings of this system.

    All memory locations in x86 systems contain 8 bits (1 byte). If a value contains more data than can fit into a single byte, it is stored using multiple bytes. For example, in C, the “float” type is stored using 4 bytes (32 bits).

    All of it looks fine except for the
    space. It has 6 bits instead of 8. I’m
    now wondering how all of that
    information is stored in memory. If
    all of it was stored in 8 bit chunks,
    like

    The space is also stored in a single byte. Your print code is forgetting to pad out to 8 spaces. 100000 == 00100000 == 0x20.

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

Sidebar

Related Questions

A recent question contains a problem that I many times used to think about
I think that I've been used to a fairly liberal policy regarding the PHP
I used to think the db/schema.rb in a Rails project stored the database schema,
I used to work in JavaScript a lot and one thing that really bothered
Is there a "very bad thing" that can happen &&= and ||= were used
I need a string->string mapping to be used at runtime (think NSDictionary ), except
I think I may have used a repeater when I should have used something
I think the following code can be used to create manipulators. #include<iostream> ostream &
I think I may misunderstand why the with command is used. But can any
Yesterday I used jQuery UI for the first time and I think I'm going

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.