answersLogoWhite

0

What do you mean by data types?

Updated: 10/23/2022
User Avatar

Wiki User

12y ago

Best Answer

Data type refers to the kind of data a variable in any programming language can hold.

For example int is used to store integer numeric values. A String is used to hold alpha numeric values.

int i = 10;

String name = "Rocky";

etc.

Each data type has its own characteristics and size.

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

9y ago

As far as the computer is concerned, all data is represented using binary values. Therefore all data has the same type: digital. In the real-world, however, data need not be digital. A person's name is not digital. A postal code is not digital. A sound wave is not digital. But in order for the computer to represent these datums we must convert them to a digital form, whether it be a single value or a sequence of values (an aggregate of values).

The computer has a finite amount of memory, so we have to impose limits upon how each value is physically represented, even when those values have an infinite range. For instance, distance can be anything from 0 to infinity and the range of real numbers between 0 and 1 is also infinite. Even the value of pi has an infinite number of digits. However, for most practical purposes we do not need to use the full range of values, we're usually only interested in a relatively small range of values. For instance, there are only 12 months in the year, thus a month can be represented by a single value in the range 0 to 11. In binary, we would need at least 4 bits to represent these values because 3 bits would only allow 8 values in the range 0 to 7:

0 = 000

1 = 001

2 = 010

3 = 011

4 = 100

5 = 101

6 = 110

7 = 111

Each bit doubles the number of representations, so with 4 bits we get 16 possible values in the range 0 to 15.

However, bits are normally grouped in sets of 8 because the smallest unit of addressable memory is a byte, and a byte is typically (but not always) 8 bits in length. Thus we would need to use at least 8-bits to store a month in numeric form, where the values 12 to 255 would be deemed invalid.

Thus we can now say that the data type required to represent a month as a number is an 8-bit byte. When presenting that number to the user, we simply add 1, such that 0 means month 1, which we interpret to mean January.

If we want to represent months by their actual name then we must map these month numbers (0 to 11) to another data type entirely; a sequence of characters (an aggregate). There are only 26 characters in the English alphabet, both uppercase and lowercase, plus 10 digits, thus in order to represent them we need a range of values from 0 to 61 at the very least. We also need punctuation marks and whitespace, as well as special symbols like £, #, %, & and *. As it turns out, we can represent the most commonly used letters, digits and symbols in just 7-bits (0 to 127), thus a single char can be represented as an 8-bit byte, which would also allow another set of 128 characters (128-255) to cater for some of the less common symbols.

Clearly a month number and a character are intrinsically the same data type; a byte. However, they are different types in terms of how they are interpreted. One returns the actual value whereas the other maps to a character in the current code page that stores all the glyphs. Thus if we change the code page, we can easily change the type of character that is presented. That's getting a bit ahead of ourselves, but it shows how the same data type can be interpreted in different ways.

A month's name is composed of several characters, thus we need a sequence of bytes to represent each of the individual characters. This is achieved through a special data type known as an array. The only criteria for an array is that we know the memory address of the start of the array and its length (in elements). In the case of character arrays (technically, an array of type char, where a char is an 8-bit byte), all the elements are 8-bits in length and we can denote the end of the array by using the null character, which is simply a byte with the value zero. Thus the word "January" can be represented by the array:

'J','a','n','u','a','r','y',0

Converting these characters to their equivalent code page values (in decimal), we get the sequence:

74, 97, 110, 117, 97, 114, 121, 0

And in hexadecimal notation we would get:

4a 61 6e 75 61 72 79 00

Since there are 8 bytes, we can easily convert this sequence to a 64-bit binary value. To achieve this, every hex digit is converted to its equivalent 4-bit "nybble" (half-a-byte), thus we get:

0100110001100001011011100111010101100001011100100111100100000000

This is the only value the computer actually "sees". But in order to convert this binary value to the word "January", it has to know what type of data it actually represents. For instance, if it were treated as a 64-bit integer, the computer would interpret this sequence as being the decimal value 5,359,686,481,972,721,920. In other words, both this value and the word "January" have the exact same binary representations. Without knowing the data type, the computer would have no way of knowing how to present this value to the user, nor how the value should be operated upon.

Knowing that the data type is specifically an array of type char, the computer will correctly interpret this value as being the word "January" (technically, it is a string of characters). The computer doesn't know what the word "January" is supposed to represent, but by knowing the type it can interpret the binary sequence correctly. The word itself is only meaningful to humans -- we recognise it as the first month of the year. But that's all that actually matters because the computer has correctly interpreted the digital data back to its real-world value, a feat that is only made possible because we specifically instructed the computer how to interpret the value, by its data type. If we actually wanted to use the value 5,359,686,481,972,721,920 itself, then we'd have instructed it to interpret the sequence as being a 64-bit integer data type instead. That, in turn, could be interpreted as being a 64-bit memory address containing yet another data type entirely, but ultimately one that can be reduced to a single, numeric value, the meaning of which is open to interpretation. That interpretation begins by simply giving the value a data type that the computer can easily interpret.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What do you mean by data types?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What do you mean by data of types?

It specifies wat type of data is stored n memory occupied


What are fundamental data types in java?

Assuming by "fundamental" you mean the primitive data types: boolean, byte, char, short, int, long, float, and double


What does conceptualisation of data mean?

it eans coceptualzing energy in different types of fuels


What does data type mean in I.C.T.?

Data is stored in databases. To make the database more efficient, different types of data are usually classified as a certain 'data type'.


Is built-in data-type are abstract data-types in java?

All built-in data types are not abstract data types.


What is datatype.Define various types of data types?

In c language data types are used to specify the tye of data.for ex:int a;It means "a" is a variable of type integer.There are two types of data types in c.They areprimary data typessecondary data typesprimary data types are the built in data types and secondary data types are the user defined data types.eg for primary data types are int,float,char,long,double..and for secondary are arrays,structures,pointers,unions..


What does data storage mean?

Data storage is the term for saving data by a computer or device. Different types of data storage work differently in a computing environment. Data storage is used to store data such as documented files, databases and for personal uses such as music and photos. Different types of data are stored in different places, depending on the type of data it is.


What are the different data types?

Theres two types of data, Continuous and discontinuous data.


What are the subject-matters of data structure?

types of data structure types of data structure


Why do you need data types?

Data types specify which types of data that an object or variable can hold. Without data types, it would be impossible to make sure that an application functions properly.


What are the different types of data?

Types of data types :Primitive data typeUser-defined data typeDerived Data typePrimitive data type:int,char,float,double,voidUser-Defined data type:class,enumeration,structure,unionDerived Data type:Arrays,Functions,Pointers.


In what types of situations would it be critical to make sure that data is linked?

It depends on what do you mean by 'linked'.