Home c++ What is the difference between `Short Int` and` int16_t`?

What is the difference between `Short Int` and` int16_t`?

Author

Date

Category

Watched a course by C++ on Coursera and there they said that you can connect the CSTDLIB library and use type data types: int16_t, uint16_t, int64_t, uint64_t , etc. Recently I learned that in the pros and how to write just Short Int, Long int , etc.

Question Actually is that there is the difference between them or is this one and the same?


Answer 1, Authority 100%

depending on the compiler and the system that you compile, the size of the built-in types (short , int , long , etc. ., In contrast, intxx_t , uintxx_t ) may differ.

In the standard (or somewhere else) you can read, in what limits the dimensions of these types may vary, but in practice, usually Short – 2 bytes, int – 4 , long – 4 or 8, Long Long – 8.

And intxx_t and uintxx_t , obviously, the size is always the same.


Answer 2, Authority 44%

short int and Long int – standard language types of dimensions of at least 16 and at least 32, respectively.

int16_t and int32_t – optionally supported aliases of types from the standard dimension library exactly 16 and exactly 32, respectively.

By the way, char8_t , char16_t and char32_t belong to the first type (i.e., keywords for non-fixed size), despite the name .

Dokops:

https://en.cppreference.com/w/cpp/language/Types

https://en.cppreference.com/w/cpp/types/integer

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions