"C Programming Language" note (ix) Reference manual 2

Source: Internet
Author: User

Basic type
The base types include multiple objects that are declared as characters large enough to store any character in the execution character set if a character in the character set is stored in an object of type char, the value of that object equals the integer encoded value of the character, and non-negative values other types of objects can also be stored in variables of type char. But the range of values, especially if it is a sign, is related to the specific implementation of an unsigned character declared with unsigned char occupies the same size space as a normal character, but its value is always non-negative with signed Char explicitly declaring a signed character with ordinary characters also occupying the same size space except Char There are also 3 types of different sizes short  Intintlong int the length of a normal int object and the architecture of the host machine determine the natural length of the same as other types of integers can satisfy a variety of special purposes enumerations are special types with integer values. A collection of named constants that is associated with each enumeration is similar to an integer type, but If the assignment of an object of a particular enumeration type is not one of its constants, or the assignment is not an expression of the same type, The compiler usually generates a warning message because these types of objects can be interpreted as numbers, so they can be collectively referred to as arithmetic types, char types, int enumeration types of various objects are collectively referred to as integral types Floatdoublelong A double is an empty collection that declares a value for a floating-point type void type, which is often used to describe a function type that does not return any value.

  

Derived types
In addition to the basic types, we can also construct derived types conceptually that derived types can have an array of infinitely multiple objects of a given type object that returns a pointer to a given type object that contains a series of objects of different types the structure of objects that contain a number of objects of different types can contain union

  

Type qualifier
An object whose type can be qualified by appending a qualifier declares that a const object represents the value of this object cannot be modified by declaring volatile an object that has an optimization-related special property qualifier that does not affect the object's range of values or its arithmetic properties

  

A.5 objects and left values
An object is a named storage area where an lvalue is an expression that refers to an object that has an appropriate type associated with the storage class identifier is an explicit example of an lvalue expression some operators can produce lvalue

  

A.6 Conversion
Depending on the operand, some operators cause the value of the operand to be converted to another type

  

Integral type Lifting
In an expression, a signed and unsigned character short integer or integer is used wherever the integer can be used, and an object of the enumerated type can be used if all values of the original type can be represented by an int, the assignment will be converted to the int type, otherwise it will be converted to unsigned int

  

Integer conversions
The method of converting any integer to a specified number of unsigned types is modulo with the maximum value that the unsigned type is capable of representing, and finding the complement representation of the smallest non-negative pair two with this integer congruence, if the bit pattern of the unsigned type is narrower, this is equivalent to a left intercept if the bit pattern of the unsigned type is wider, Equivalent to symbolic expansion of signed values and 0 padding on unsigned values converts any integer to a signed type, if it can be represented in a new type, its value remains the same or its value is related to the specific implementation

  

Integers and floating-point numbers
When you convert a floating-point number to an integer, the fractional part is discarded if the structure value cannot be represented by an integer, its behavior is undefined in particular, the result of converting a negative floating-point number to an unsigned integer is undefined when converting an integral type to a floating-point type, if the value is within the range that the floating-point type can represent but not The result may be the next higher or lower value if the value exceeds the range that can be represented, its behavior is undefined

  

Floating-point types
When you convert a low-precision floating-point type to the same or high-precision floating-point type, its value remains the same when you convert a high-precision to ground precision, the result may be the next higher or lower, if its value is within the range that can be represented. If the result is outside the scope of the expression, its behavior is undefined

  

Arithmetic type conversions

Many operations cause type conversions in a similar way during operations and produce results whose effect is to convert the operands to the same public type, and as a result type the conversion of this way is called a normal arithmetic type conversion

  

Pointers and integers
The pointer can add or subtract an integer expression. In this case, the conversion of an integral expression is performed by the addition operator two pointers to objects of the same type in the same array can be subtracted, The result is converted to an integer conversion in the way that the subtraction operator makes an integral constant expression of value 0 or an expression that is cast to a void * type can be cast to any type of pointer by a cast assignment or comparison operation the result will be a null pointer, which is equal to another null pointer of the same type. But not equal to any pointers to functions or objects also allow some other pointers-related conversions, whose results depend on concrete implementation pointers that can be converted to integral types, but this integral type must be large enough to be explicitly converted to pointers to one type of pointer that can be converted to pointers to another type, but If the object that the pointer points to does not meet a certain storage alignment requirement, the result pointer may cause an address exception to point to a pointer to an object that can be converted to a pointer to an object with a smaller or identical storage alignment limit, and can guarantee that the concept of an intact transition back to alignment relies on a specific implementation. But an object of type char has the smallest alignment limit one pointer can be converted to another pointer of the same type to a pointer to a function that can be converted to a pointer to another function

  

void
Void object values cannot be used in any way, nor can they be explicitly converted to any non-null type

  

Pointer to void
Pointers to any object can be converted to void * types without loss of information if you convert the result back to the initial pointer type, you can restore the initial pointer to the pointer to the conversion, which generally requires an explicit cast here, the pointer can be assigned a pointer of type void *, You can also assign a pointer to a void * type and compare it to a pointer of type void *

  

"C Programming Language" note (ix) Reference manual 2

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.