1. The integer types in C language include char, short, int, long, etc. The following are the regulations on the length of each data type in C language:
(a). The lengths of short and long types are different. Same
(b). The int type is usually the same as the physical word length of the specific machine
(c). short is usually 16bits, int is usually 16bits or 32bits. Each compiler can freely determine it according to different hardware, but short and int must be at least 16 bits, and long type must be at least 32 bits, and short must be shorter than int and long types.
2. The sizeof() operator returns the number of bytes (bytes) contained in a data type. AnsiC stipulates that sizeof(char) must return 1. When sizeof is applied to an array, the returned It is the number of bytes occupied by all members in the array (note that it is not the number of members in the array). When sizeof() is applied to structures and public bodies, it returns not only the total number of bytes of data members, but also Includes those bytes padded by the compiler to implement byte alignment.
I used to vaguely understand these rules when writing programs, but I always thought that the char type must be 8 bits. However, I recently did an embedded DSP project, and the compiler manual clearly stated that the char type is 16 bits. , but I had no choice but to dig out "The C Programming Language" and found out that ANSI C does not have a rigid requirement for the length of the char type. In the past, I didn’t pay much attention to the portability of data types when writing programs. All previous codes used in this project have to be re-examined for data type length issues.
C++ data type length issues:
1. Bytes and word length
Bytes, eight bits are one byte, which is a fixed concept. Word length refers to the length of binary data that the computer can process at one time. It is a non-fixed concept. For example, the word length of an 8-bit computer is 8, which is one byte, and the word length of a 32-bit computer is 32, or 4 bytes. Similarly, the word length of a 64-bit computer is 64, or 8 bytes.
2. Data types in C++
1. Character data char, this type is always one byte long, that is, 8 bits.
2. Integer, short int and long integer. Usually int is one word long, short is half a word long, and long is one or 2 words long (one word long on a 32-bit machine).
3. Float, double, and long double represent single-precision floating-point numbers, double-precision floating-point numbers, and extended-precision floating-point values respectively. Typically, float is one word, double is two words, and long double is three or four words.
The length of each data type in Java:
boolean depends on the trial compilation environment
byte 1 byte
short 2 bytes
char 2 words Section
int 4 bytes
long 8 bytes
float 4 bytes
double 8 bytes
More java and c/c++ data type lengths For more related articles, please pay attention to the PHP Chinese website!

Analysis of class loading behavior of SPI mechanism when Tomcat loads Spring-Web modules. Tomcat is used to discover and use the Servle provided by Spring-Web when loading Spring-Web modules...

Confused with choosing Java project management tools for beginners. For those who are just beginning to learn backend development, choosing the right project management tools is crucial...

Regarding the implementation principles and methods of listening events In programming, listening to events is a common requirement, especially listening for changes in a certain value. Many people may...

How to dynamically configure the parameters of entity class annotations in Java During the development process, we often encounter the need to dynamically configure the annotation parameters according to different environments...

Analysis of the reason why Python script cannot be found when submitting a PyFlink job on YARN When you try to submit a PyFlink job through YARN, you may encounter...

The difficulties encountered when calling third-party interfaces to transmit data in SpringBoot project will be used for a Spring...

In IntelliJ...

How to convert names to numbers to implement sorting within groups? When sorting users in groups, it is often necessary to convert the user's name into numbers so that it can be different...


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version
Useful JavaScript development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.