In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
In this issue, the editor will bring you about the types of C language. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
Bit width of data type types in C language
Compared with the high-level language, the integer data type of C language has a fixed width, that is, how many bits the type occupies. For example, the following data types:
Signed charunsigned charsigned shortunsigned shortsigned intunsigned intsigned longunsigned longsigned long longunsigned long long
The bit widths of these types may vary somewhat depending on the platform, but it is certain that each platform has a fixed bit width. In order to specify the bit width clearly in the programming process, increase the readability of the code and avoid platform dependence, each platform defines its own basic types of bit width. For example, the following types are defined in the stdint.h header file on the Linux platform.
Int8_tuint8_tint16_tuint16_tint32_tuint32_tint64_tuint64_t
Each type specifies a symbol and a bit width, and you can literally see what the bit width of this type is. Due to the existence of bit width, each type has its own maximum and minimum values. For example, Linux defines the maximum and minimum values for each type respectively (the minimum value for unsigned numbers is 0).
INT8_MININT8_MAXINT16_MININT16_MAXINT32_MININT32_MAXINT64_MININT64_MAXUINT8_MAXUINT16_MAXUINT32_MAXUINT64_MAX
With these definitions, C language operations basically need these boundary values, otherwise it will cause the legendary integer overflow problem. For example, the addition and multiplication operations need to be judged as follows:
/ calculate the sum of the two values uint32_t sum (uint32_t a, uint32_t b) {/ * first determine whether the addition will overflow. Note that (aquib) (unsigned char) 0) {printf ("unsigned char a > 0\ n") {printf ("unsigned > 0\ n");} / / not true, an is not converted to `unsigned `if (a > (unsigned short) 0) {printf ("unsigned char a > 0\ n"). } / / convert a to `int`if (a > (unsigned int) 0) {printf ("unsigned int a > 0\ n");} these are the types of C language shared by the editor. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.