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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:30:00+00:00 2026-06-08T21:30:00+00:00

I am going to be using very small numbers in really large quantities (As

  • 0

I am going to be using very small numbers in really large quantities (As in each int will be between 1 and 10 and have 100s of variables like this at a time) for the first time, and I was wondering if there was any significant performance differences in using 16 bit integers VS 32 bit. Most of my users will be using 64 bit processors but some will have 32 bit.

  • 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-08T21:30:02+00:00Added an answer on June 8, 2026 at 9:30 pm

    CPU

    When working with individual numbers, there will possibly be a slight improvement using a more compact representation. That is,

    ushort a;
    ushort b;
    
    // @mikez pointed a & b are  promoted to int when added
    // C# spec, 7.3.6.2 Binary numeric promotions
    ushort result = (ushort)(a + b); 
    

    might be slightly faster than

    ulong a;
    ulong b;
    
    ulong result = a + b;
    

    depending on your algorithms. The reason is that more data can fit in CPU cache when the individual numbers are smaller, and ultimately less data has to be transferred from RAM to the CPU.

    On the other hand, it might be slightly slower due to reading/writing data that is not aligned to a 64-bit address boundary.

    Both factors work against each other. Measure your use cases to find out if you’re better or worse off from a CPU perspective.

    In RAM

    Using a List<ushort> instead of a List<ulong> will save 75% in terms of memory cost. If this prevents swapping, it will benefit your application.

    On Disk

    If you are saving to a database, and if your working set is too large to fit in RAM available to the database engine, using the smaller size can have a huge difference on performance because more records fit onto fewer sectors of your disk reducing disk seek time (assuming no SSD) and increasing the amount of data points that can be transferred through the IO channel per unit time.

    Caveat

    Note that all of this only matters if really large quantities is true in comparison to the processing power of your computer. If you have enough RAM to keep all data in memory, you will not swap. If your database server and/or storage controller cache can keep your working set in memory, disk storage size considerations will matter little.

    Bottom Line

    Using a smaller data type will only hurt you if you were wrong about the range of values you will process, and you suddenly need a larger data type to hold all values.

    Do a quick prototype of your key algorithms. Perform some measurements using various choices of ushort, uint, ulong.

    If your “100’s of variables” each only contain a single number (as opposed to, say, a list with lots and lots of numbers), none of this matters. Only when you start to put pressure on your computer (maybe in 10’s to 100’s of millions of data points or more, depending on what you are doing) will these optimizations matter in a real way to your users.

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

Sidebar

Related Questions

I have a Java app that fetches a relatively small .zip file using a
I have just started working with a new company in a very small IT
I'm working on a small, very application-specific CMS. There's nothing financial going on, and
I have written a small webapp using the flask framework that involves plotting using
I am using Rhino Mocks. I have a data repository, a small part of
We are going to start a very small web development project. The team has
I have a small C# library with a static class that holds a very
I want to create a very small application using java to understand about the
I am using JDK 7 and Netbeans IDE 7.1.2. Going through Using string in
I was going to start using === (triple equals, strict comparison) all the time

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.