Internet
Fact-checked

At EasyTechJunkie, we're committed to delivering accurate, trustworthy information. Our expert-authored content is rigorously fact-checked and sourced from credible authorities. Discover how we uphold the highest standards in providing you with reliable knowledge.

Learn more...

What Is Primitive Data Type?

Alex Tree
Alex Tree

A primitive data type is a computer science term used to describe a piece of data that exists within a computer programming language by default. Typically, the values of these types of data cannot be changed by a computer programmer. For example, if a computer program was a brick wall, primitive data types would be a special type of brick that could not be broken down or further refined. An example of a piece of primitive data is the character “a”; this character means itself and is used to represent more complicated pieces of information by combining it with other pieces of information. While the precise primitive data types that are available in any given computer programming language vary from language to language, integers and characters are basic primitive data types available within most of them.

The “character” is one of the basic primitive data types available within most computer programming languages, and it is sometimes referred to in the shortened form “char.” This data type includes most of the single symbols that can be inputted into a computer with a single keystroke, such as the numeral symbol “5,” punctuation marks such as “.”, and the letter “b.” The term character does not only mean letter, number or punctuation mark, however. Control characters such as delete, tab, and backspace also fall under the primitive data type character.

Woman doing a handstand with a computer
Woman doing a handstand with a computer

In general, anything that is a primitive data type is also a value type, which means the data is not very picky. The data does not always have to be recorded in the same way. For instance, it does not usually matter what order the bytes describing the data are recorded in.

One area that some programming languages vary on is their treatment of strings. As a computer science term, a string is a sequence of symbols, such as characters. Some programming languages build in support for strings and treat them as a primitive data type while other languages do not have as basic support for the data type.

Integers are an area where computer hardware can affect the treatment of primitive data types. In computer science terminology, an integer represents one or more mathematical integers. Different central processing units (CPUs) have different limits on how many bytes can be used to represent an integer. At times, this is something that computer programmers keep in mind so that their programs can run on as many different types of CPUs as possible.

Discussion Comments

MrMoody

@hamje32 - My understanding is that the reference data type is a data type that can be passed to a routine by reference. That sounds like a circular explanation, so let me dig a little deeper.

I think that reference data types can be accessed through pointers, if you remember what those are. This is an indirect way of accessing a variable by referring to its memory location, rather than by referring to the variable name itself.

The flip side of the reference data types, if I recall, is the value data types. Those are data types that you use by referring to the variable name directly.

hamje32

@SkyWhisperer - Does anyone know what a reference data type is? I ran across this concept when looking at different programming languages but I’m not too sure what it is or what it’s supposed to do.

My background, too, was in BASIC, when life was much simpler.

SkyWhisperer

@allenJo - Yeah, I imagine that would be important. I am not a professional programmer myself; I do some hobby programming in BASIC, where the data types are quite general and enforcement of the types is loose.

In one particular flavor of BASIC I can even use what’s called a variable data type, which means that it can hold just about anything – an integer, a float, a string or whatever.

I don’t know how the computer figures out how to treat the variable type. Maybe it just determines how to classify it internally based on its representation.

So I suppose it would look at a decimal number and determine to internally represent it as a float or double. I don’t know. All I know is that the variable data type is very convenient for me when I code.

allenJo

I worked on a software project on my workplace using .NET as the programming language. I ran into a hurdle when I tried to port the program from legacy C to .NET. The reason is that some primitive data types in .NET are a little different.

For example, in C you have an integer that is 16 bits in length. In .NET you have to use the “short” primitive data type if want to get the equivalent to the C integer data type. Before I realized this, I was using the .NET integer data type which was 32 bits, and as a result my program was returning incorrect values.

It definitely helps to use the right data type for your project.

Post your comments
Login:
Forgot password?
Register:
    • Woman doing a handstand with a computer
      Woman doing a handstand with a computer