A Complete Guide to Programming in C++ part 5

A Complete Guide to Programming in C++ part 5. This book provides both novice and experienced programmers with a comprehensive resource manual for the C++ programming language. Readers gain experience in all aspects of programming, from elementary language concepts to professional software development, with in depth coverage of all the language elements en route. These elements are carefully ordered to help the reader create useful programs every step of the way. | FUNDAMENTAL TYPES CONTINUED Integral Types The types short int and long are available for operations with integers. These types are distinguished by their ranges of values. The table on the opposite page shows the integer types which are also referred to as integral types with their typical storage requirements and ranges of values. The int integer type is tailor-made for computers and adapts to the length of a register on the computer. For 16-bit computers int is thus equivalent to short whereas for 32-bit computers int will be equivalent to long. C treats character codes just like normal integers. This means you can perform calculations with variables belonging to the char or wchar_t types in exactly the same way as with int type variables. char is an integral type with a size of one byte. The range of values is thus -128 to 127 or from 0 to 255 depending on whether the compiler interprets the char type as signed or unsigned. This can vary in C . The wchar_t type is a further integral type and is normally defined as unsigned short. The signed and unsigned Modifiers The short int and long types are normally interpreted as signed with the highest bit representing the sign. However integral types can be preceded by the keyword unsigned. The amount of memory required remains unaltered but the range of values changes due to the highest bit no longer being required as a sign. The keyword unsigned can be used as an abbreviation for unsigned int. The char type is also normally interpreted as signed. Since this is merely a convention and not mandatory the signed keyword is available. Thus three types are available char signed char and unsigned char. NOTE In ANSI C the size of integer types is not preset. However the following order applies char short int long Moreover the short type comprises at least 2 bytes and the long type at least 4 bytes. The current value ranges are available in the climits header file. This file defines constants such as CHAR_MIN CHAR_MAX INT_MIN

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.