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

  • Home
  • SEARCH
  • 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 6014821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:44:53+00:00 2026-05-23T02:44:53+00:00

Programming languages (e.g. c, c++, and java) usually have several types for integer arithmetic:

  • 0

Programming languages (e.g. c, c++, and java) usually have several types for integer arithmetic:

  • signed and unsigned types
  • types of different size: short, int, long, long long
  • types of guaranteed and non guaranteed (i.e.implementation dependent) size:
    e.g. int32_t vs int (and I know that int32_t is not part of the language)

How would you summarize when one should use each of them?

  • 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-23T02:44:54+00:00Added an answer on May 23, 2026 at 2:44 am

    The default integral type (int) gets a “first among equals” preferential treatment in pretty much all languages. So we can use that as a default, if no reasons to prefer another type exist.

    Such reasons might be:

    • Using a bigger type if you know you need the additional range, or a smaller type if you want to conserve memory and don’t mind the smaller range.
    • Using an unsigned type to make sure that you don’t get any “extra” 1s in your integer representation if you intend to use bit shifting operators (<< and >>).
    • If the language does not guarantee a minimum (or even fixed) size for a type (e.g. C/C++ vs C#/Java), and you care about its properties, you should prefer some mechanism of generating a type with guaranteed size (e.g. int32_t) — if your program is meant to be portable and expected to be compiled with different compilers, this becomes more important.

    Update (expanding on guaranteed size types)

    My personal opinion is that types with no guaranteed fixed size are more trouble than worth today. I won’t go into the historical reasons that gave birth to them (briefly: source code portability), but the reality is that in 2011 very few people, if any, stand to benefit from them.

    On the other hand, there are lots of things that can go wrong when using such types:

    • The type turns out to not have the necessary range
    • You access the underlying memory for a variable (maybe to serialize it) but due to the processor’s endianness and the non-fixed size of the type you end up introducing a bug

    For these reasons (and there are probably others too), using such types is in theory a major pain. Additionally, unless extreme portability is a requirement, you don’t stand to benefit at all to compensate. And indeed, the whole purpose of typedefs like int32_t is to eliminate usage of loosely sized types entirely.

    As a practical matter, if you know that your program is not going to be ported to another compiler or architecture, you can ignore the fact that the types have no fixed size and treat them as if they are the known size your compiler uses for them.

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

Sidebar

Related Questions

In several modern programming languages (including C++, Java, and C#), the language allows integer
different programming languages have different features or lack certain features. Design patterns are a
Several questions about functional programming languages have got me thinking about whether XSLT is
Some programming languages such as Java and C# include encryption packages in their standard
Java is one of my programming languages of choice. I always run into the
Programming languages had several (r)evolutionary steps in their history. Some people argue that model-driven
I use Java where we only have packages. I know there are other programming
My first serious language was Java, so I have comprehended object-oriented programming in sense
I'm currently working with a specialized, interpreted, programming language implemented in Java. As a
How can I, in Java or using some other programming language, add a new

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.