Linux basic data type size--int,char,long int,long long int

Source: Internet
Author: User

Transferred from: http://paddy-w.iteye.com/blog/1403217

In the Linux operating system using GCC programming, the current general processor is 32-bit word width, the following is the/usr/include/limit.h file on the Linux data type limitations and storage byte size description.
/* We have #include_next.  Define ANSI <limits.h> for standard 32-bit words. */
/* These assume 8-bit ' char ' s, 16-bit ' short int ' s, and 32-bit ' int ' s and ' long int ' s. */
1.char Data types
The char type data occupies a memory space of 8 bits. Where is the value range of the symbolic character type variable? 128~127, the value range for unsigned character variables is 0~255. The restrictions are as follows:
/* Number of bits in a ' char '. */
# define Char_bit 8//Of bytes occupied
/* Minimum and maximum values a ' signed char ' can hold. *///signed character type range
# define SCHAR_MIN (-128)
# define Schar_max 127
/* Maximum value a ' unsigned char ' can hold. (Minimum is 0.) *//unsigned character range
# define UCHAR_MAX 255
/* Minimum and maximum values a ' char ' can hold. */
# ifdef __CHAR_UNSIGNED__
# define Char_min 0
# define Char_max Uchar_max
# Else
# define Char_min schar_min
# define Char_max Schar_max
# endif
2.short int data type
The short int type data occupies a memory space of 16 bits. Where is the signed short integer variable value range? 32768~32767, unsigned short integer variables have a range of 0~65535. The restrictions are as follows:
/* Minimum and maximum values a ' signed short int ' can hold. *///Signed short-integer range
# define Shrt_min (-32768)
# define Shrt_max 32767
/* Maximum value an ' unsigned short int ' can hold. (Minimum is 0.) */
Unsigned short-integer range
# define Ushrt_max 65535
The 3.int data type int type data occupies a memory space of 32 bits. The value range of the signed integer variable is -2147483648~2147483647, and the value range of the unsigned integer variable is 0~4294967295u. The restrictions are as follows:
/* Minimum and maximum values a ' signed int ' can hold. *//Shaping Range
# define INT_MIN (-int_max-1)
# define Int_max 2147483647
/* Maximum value an ' unsigned int ' can hold. (Minimum is 0.) */
Unsigned shaping range # define Uint_max 4294967295U
4.long int data type
As the macro __wordsize value changes, the size of the long int data type also changes. If the value of __wordsize is 32, a long int is the same as the int type and occupies 32 bits. In the Linux gcc4.0-i386 version, the value of __wordsize is 32 by default. It is defined as follows:
Come from/usr/include/bits/wordsize.h
#define __WORDSIZE 32
On a 64-bit machine, if the value of __wordsize is zero, the long int data occupies a memory space of 64 bits. There is a long integer variable value range of -9223372036854775808l~9223372036854775807l, unsigned long integer variable value range is 0~18446744073709551615ul. The restrictions are as follows:
/* Minimum and maximum values a ' signed long int ' can hold. *///Signed Long shaping range
# if __wordsize = = 64
# define Long_max 9223372036854775807L
# Else
# define Long_max 2147483647L
# endif
# define LONG_MIN (-long_max-1l)

/* Maximum value a ' unsigned long int ' can hold. (Minimum is 0.) *///unsigned long shaping range
# if __wordsize = = 64
# define Ulong_max 18446744073709551615UL
# Else
# define Ulong_max 4294967295UL
# endif
5.long long int data type
In C99, a long long int data type is also defined. Its data types are limited as follows:
# ifdef __USE_ISOC99
/* Minimum and maximum values a ' signed long long int ' can hold. *///unsigned long shaping range
# define Llong_max 9223372036854775807LL
# define LLONG_MIN (-LLONG_MAX-1LL)
/* Maximum value a ' unsigned long long int ' can hold. (Minimum is 0.) *///signed long shaping range
# define Ullong_max 18446744073709551615ULL
# endif/* ISO C99 */

Linux basic data type size--int,char,long int,long long int

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.