Understanding software Development in advance (5) redefining some basic data types

Source: Internet
Author: User
Tags define integer variables

Defining variables is essential when writing programs, and some basic data types are used.

Perhaps you would say that it is easy to define a variable with any difficulty. To define an integer variable, use "int i;" directly. statement, and to define character variables, use "char C;" directly. It's OK. Indeed, this is what school education teaches us, but it cannot be done in practical work.

Why, then? The reason is simple, because the program is written so that it looks very "cottage", not a professional programmer should do things.

Some time ago, I was watching " Chu Han legend ", there is a scene left me a very deep impression. When Liu Bang for the first time to find the help of Xiang Yu, they saw a line of Xiang Yu Camp is how to training, think of their own training methods, then shocked. Liu Bang they are completely like a group of no norms, running around the farmers, compared with Hang Jiajun, really bad far. This difference is transplanted to software development, which is the difference between " Shanzhai " and " professional ". Although this analogy is a bit inappropriate, it also shows a certain truth.

The basic data types of books to go to school is like a child who is not sensible, only to carry out certain norms and training, in order to get out of society, can be used for units.

Based on your own work experience, some of the basic data types that are commonly used are redefined (normalized) as follows:

(1) Integral type

An integral type that consists of a short int, an integer (int), and a long integer (long int) with a number of digits to include unsigned integer (unsigned) and signed Int (signed).

For unsigned short integers, it is redefined as: typedef unsigned-intUINT16;

For a signed short integer, it is redefined as: TypeDef signed-intINT16;

For unsigned integral type, it is redefined as: typedef unsigned INTUINT32;

For signed integral type, it is redefined as: TypeDef signed INTINT32;

For unsigned long integer, it is redefined as: typedef unsigned longulong;

For signed long Integer, it is redefined as: TypeDef signed Longlong;

By redefining the above, we can use UINT16, INT16, UINT32, INT32, ulong, and long to replace the corresponding integer type. Here take UINT32 to explain: "U" stands for "unsigned", "int" represents "int", "32" means "32 bits", from this definition you can see that this represents a 32-bit unsigned integer data type, and if you want to define one such variable i, use "UINT32 i;" The statement is OK.

More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/project/

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.