We use different types of data to make sense of the concepts and objects around us in different ways. Computers need “data” in order to produce solutions.
Raw data is perceived as “input” by the computer and processed through the program. The value returned to the user is the processed data; It is called “output” or “information”. It must be specified which data type the computer is working with. Different types of data can be processed in a program. For example, integers, fractional numbers, characters, symbols, text, and logical values make up data types.
Numeric data includes all number types. Numeric data is the only data type that can be used in computational operations. Positive or negative integers and real numbers can be used.
Numerical data; Angles are defined for the required values in the calculation process, such as distance, population, charge, radius. There is also numeric data that is not used for calculation, such as a bank account number or zip code. Such data is not numerically defined. Each data type has a data set. The data set defined for numeric data includes the numbers 0-9 and the “+” and “–” signs. For example, 66578 and -2356 are examples of integers. Real numbers include all real and decimal numbers. For example -56.23, 8695.235 or 0.005 are examples for real numbers.
The minimum and maximum values that numbers can take may vary depending on the computer and programming language used.
Character data set; all single digit numbers (“0”.. “9”), letters (“a”..“z”, “A”..“Z”) and special characters (“#”, “&”, “*” , ..) covers. The value generated from this dataset is specified in quotes. It is case sensitive, so “a” and “A” are perceived differently. The character set, called ASCII (American Standard Code for Information Interchange), consists of 256 characters. Even if the characters are only numbers, they cannot be used in calculations.
If more than one character is put together, the computer calls this structure a “string”. Character and string data can be compared and sorted in alphabetical order. The computer assigns a number to each character and performs the operation in this way because computers are devices that can perform numerical operations. Data are compared with each other and sorted in descending or ascending order. For example, when comparing Banana to Apple, since the letter M has a larger number than the letter E, the value of the series Banana is greater. When Elif and Esra are compared, Esra gets a higher value because the letter s comes after the letter l. Uppercase letters have lower numerical values than lowercase letters.
Characters and strings can be linked together using the + operator. This process, called merging, brings two pieces of characters together. For example, “6”+“6” = “66”. Generally, it is recommended to define data that does not require mathematical operations as arrays.
Logical data contains only two words in the dataset: true and false. This data is used in yes or no decision making processes. For example, logical data definition is made in cases where the result is true or false, such as whether the obtained value is the expected value, whether he is married, has a car, or whether the student is a high school graduate. These words are reserved special words and are not perceived as strings.
Rules for Data Types
- The data you define should usually be numeric, character, string or logical.
- The programmer specifies the name and type of data in the programming process. When the computer starts up, it matches the name of the data with its type.
- Data types cannot be mixed. For example, a numerically defined data cannot be perceived as a string. In this case, the computer does not meet the expected data type and gives an error.
- Each data type uses the data set defined for itself.
- All data to be used in mathematical operations should be defined as numeric, others as characters or strings.
- Programmers can also create their own defined data types. These so-called user-defined data types can create structures containing both string and numeric data such as today’s date, destination, time to arrive.