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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:32:20+00:00 2026-05-20T08:32:20+00:00

A long time ago I remember reading that you should always use the smallest

  • 0

A long time ago I remember reading that you should always use the smallest possible type to store your data, but nearly every piece of code I read doesn’t do this. They often use 32 bit integers all over the place.

I’ve heard the rationale that a 32 bit value is fetched as fast as an 8 bit value, but processors have some way of fetching several smaller values at once.. Right?

So if I use 4 bytes instead of 4 integers, shouldn’t the compiler be able to optimize this so the 4 bytes is fetched/stored in a single 32 bit register?

Or is all of this really just premature optimization and the potential performance gain is negligible?

  • 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-20T08:32:20+00:00Added an answer on May 20, 2026 at 8:32 am

    Premature optimization indeed! However, once you are optimising, it also depends on your architecture. For example, on ARM, memory accesses must be 32-bit aligned (some instructions can do this, but they just do a 32-bit access then mask/shift behind the scenes). If you use a byte, a compiler will often give each ‘byte’ four actual bytes of RAM so it can be accessed faster (not to mention the CPU will freak outif you try to access unaligned bytes without special code to handle them).

    There is an argument to using ‘int’ for everything since it’s the CPU’s preferred size, but basically, just use the type of the size you need, and let the compiler worry about optimisations 😀

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

Sidebar

Related Questions

I remember reading somewhere (a long time ago) that sprites - or at least
A long time ago I had an apple ][ . I remember the command
For a long time ago, I have thought that, in java, reversing the domain
Long time ago, I was creating a mini ORM using reflection. While reading about
A long time ago I remember I could do this in Turbo Pascal 7.
A long time ago I used to program in C for school. I remember
I am reusing a curl function from a long time ago that is now
A long time ago I used to use or die in my PHP code.
A long time ago, I remember using some Solaris make, and they had an
Long time ago, the Game Developer magazine published an article about ID Software and

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.