Concise Data Type Guide and Data Type Guide

Source: Internet
Author: User

Concise Data Type Guide and Data Type Guide
Common Data Types

  • Char: characters are stored in computer memory in the form of character encoding. character encoding is A number. Therefore, in computer opinion, A is exactly the same as number 65 (65 is the ASCII code of ).
  • Int: If you want to save an integer, you can usually use int. The size of the int in different computers is different, but it should have at least 16 bits. Generally, an int can store numbers of tens of thousands or less.
  • Short: Generally, it is only half the size of an int. Therefore, if you only want to save hundreds or thousands of numbers, you can use this data type.
  • Long: Generally, it is twice the size of an int, and should have at least 32 digits. Therefore, it can store numbers of billions or less. However, the size of long and int in most computers is the same, in these computers, int itself is very large.
  • Float: it is the basic data type that stores floating point numbers.
  • Double: If you want to make the calculation result accurate to many digits after the decimal point, you can use double. Double is twice the space of float and can store larger and more precise numbers.

 

Program Verification

Next we will verify it with a program:

 

# Include <stdio. h> # include <limits. h> // There are also integer size values # include <float. h> // contains int main () {printf ("The value of INT_MAX is % I \ n", INT_MAX ); // printf ("The value of INT_MIN is % I \ n", INT_MIN); // printf ("An int takes % I bytes \ n ", sizeof (int); // printf ("The value of FLT_MAX is % f \ n", FLT_MAX ); // float printf ("The value of FLT_MIN is % f \ n", FLT_MIN); printf ("An float takes % I bytes \ n", sizeof (float )); printf ("The value of CHAR_MAX is % I \ n", CHAR_MAX); // char printf ("The value of CHAR_MIN is % I \ n", CHAR_MIN ); printf ("An char takes % I bytes \ n", sizeof (char); printf ("The value of DBL_MAX is % lf \ n", DBL_MAX ); // double printf ("The value of DBL_MIN is % lf \ n", DBL_MIN); printf ("An double takes % I bytes \ n", sizeof (double )); printf ("The value of SHRT_MAX is % I \ n", SHRT_MAX); // short printf ("The value of SHRT_MIN is % I \ n", SHRT_MIN ); printf ("An short takes % I bytes \ n", sizeof (short); return 0 ;}

 

The result is as follows:

 

Thoughts

Question: What does and 64-bit mean?

A: Technically speaking, the number of digits in a computer has many meanings. It can represent the length of a CPU instruction or the size of data that the CPU reads from the memory at a time. In fact, the number of digits is the length of the value that the computer can process.

 

Question 2: What does this have to do with the size of int and double?

A: If a computer can process 32-bit values, the basic data type (such as int) is set to 32-bit.

Related Article

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.