Data types in computer science. Type integer

By the end of 2018, there are several hundred programming languages ​​in the world, the smaller part of which is represented by highly specialized languages, such as, for example, Ada (a language invented by the U.S. Air Force for controlling ballistic missiles) or Fortran, which is mainly used in scientific software development. But most of them are open to understanding and study and are widely used.

Data types in computer science are a structural and dimensional characteristic of a allocated memory cell, in which you can put some value for further operations. One of these types is the integer (int) type. This is an integer data type. That is, only an integer (0, 1, 2, 256, 10000, and so on) can be placed in a reserved cell of type integer.

The range of values ​​that can be put in an integer type cell differs in other programming languages ​​and on different processors, for example, in the Pascal programming language, it ranges from -32768 to 32768. Attempting to “put” data larger or smaller than this range will cause a “data overflow error”.

Integer data type characteristics

In 32-bit architectures, they occupy from −2 147 483 648 (-2 31 ) to 2 147 483 647 (2 31 −1)

  • It is stored as an integer.
  • The range varies from the choice of programming language and architecture.
Integer variable




There are integer types, without signs. For example, unsigned int in C #. Misuse of these types of data can lead to errors.





There are also various variations of the integer type, such as:

  • short int - is intended to reduce the amount of memory allocated for the needs of the programmer.
  • long int - on the contrary, it was created for those who are afraid that during the work of the program there is a risk of “flying out” beyond the limits of a regular int and getting a “data overflow error”.

The types integer, real, dint (in the Pascal language) are mathematical data types. This means that it is possible to perform mathematical operations - addition, multiplication, subtraction, division.

Integer real type characteristics

To store a real number in RAM, six bytes of memory are allocated, therefore, calculations are always performed with finite accuracy, depending on the format of the number. Real data is stored as an integer with a floating decimal point.

Other data types in popular programming languages

Data types




Char is a character data type; it can store 1 character from an ASCII character table. It occupies 1 byte and is interpreted as an ASCII character.

String is a string data type, usually represented by an array of char objects. Typically, the capabilities of modern languages ​​allow you to perform a variety of actions on objects of type string, for example, concatenation (gluing), deleting strings, replacing characters in a string.





Boolean is a logical data type. Primitive data type in computer science expressing 2 states. Very useful when the program needs to express only 2 states (for example, write a function that would return only truth or falsehood).

Cast

Programming languages ​​allow you to "cast" types to each other. For example, by initializing a variable of type integer, we can later cast it to type double, that is, allow the compiler to overwrite it and treat it later as a floating-point number.

But not all data types can be converted so easily. For example, we won’t bring string to integer, the compiler just won’t understand our actions. There are also special cases of compilers and programming languages. For example, in Pascal, you cannot convert the integer type to integer real, because only the real type supports the division operation.

Cast




In modern languages, such as C #, there are no such problems, most often a programmer can painlessly convert intuitively similar data types, such as int. double, long int and so on. Moreover, in dynamically typed languages, it is even possible that a char data type is cast to int!

This is allowed because the compiler, instead of working with a character, takes its serial number from the ASCII table and already uses it to interact with int. In strongly typed languages ​​such as C ++ or C #, this, of course, is not possible.

Object oriented programming




These are the main types of data in computer science. In modern programming languages, variables often are no longer just allocated space in RAM, but entire “objects” or “classes”, which greatly expands the possibilities of operations with them.

To understand how such complex structures are stored, you need to delve into such an inexhaustible topic as object-oriented programming, the most advanced tool for creating powerful, extensible and supported by years of programs.




All Articles