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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:13:00+00:00 2026-05-23T18:13:00+00:00

can somebody explain me what the advantage of small data types like char (8-Bit)

  • 0

can somebody explain me what the advantage of small data types like char (8-Bit) or short (16-Bit) compared to int (32-Bit) (esp. in C/C++).

In my mind it does not bring any advantage esp. on a 32-Bit machine, because of its word size is always 32-Bit. Is it a compiler thing, that in some cases some small types can be combined in one register, to save memory? So are small data types just intended for hardware architectures lower than 32-Bit or/and with little memory?

Additional I see a new target for failures by overflowing the data type, so I hink it shouldn’t be lightly used…

  • 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-23T18:13:01+00:00Added an answer on May 23, 2026 at 6:13 pm

    Even if the machine has a word size of 32 bit, doesn’t mean that all the data types are stored in word boundary, or even that the minimum unit of information storage is the word. Say that you have to create a vector of a thousand characters. If you create it like this:

    std::vector<char> v(1000);
    

    it will use around a thousand bytes (usually). If you assume that the minimum storage unit is the word, you could declare it instead like this (thinking that anyway each char will use a 32 bit word):

    std::vector<int> v(1000);
    

    but this will give you around 4 bytes * 1000, which is four times the previous declaration.

    That is, sometimes, and depending on how you declare your types, they get packed, so they don’t use a word for storing each piece of information. In the first case, the compiler/implementaiton of vector<char> will create a buffer of 1000 bytes to store all the chars packed.

    So, the answer would be that the advantage is saving memory space.

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

Sidebar

Related Questions

Can somebody explain me why the small piece of code doesn't work? This is
Can Somebody explain me on short (just as idea) what the following fragment suggests?
It's feel like I'm stuck, my friends. Can somebody explain me pick equations from
Can somebody explain me what the following bit of code in Matlab is doing?
Hello Can somebody explain why second cout in func(char *p) doesn't work: #include <cstdlib>
Can somebody explain the main differences between (advantages / disadvantages) the two implementations? For
Can somebody explain to me what the below code is doing. before and after
Can somebody explain to me what this does in javascript? (function (x,y){}(x,y)); or this
Can somebody explain to me why the following works: template<class T> class MyTemplateClass {
Can somebody explain why the following code is not valid? Is it because the

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.