Primative Data Types | |||||||||||||||||||||||||||||
There are only a few primitive data types used in most computers. These data types have a specific size and encoding scheme. Below is a table which shows all of the available data types
Classes in most languages are considered a data type. These will be made up of one or more primitive data types as shown above. When defining a variable you must specify its data type. Due to the encoding schemes used you can not directly compare different types together. For example it is not possible to compare a real number to a integer. Programming languages get around this by converting them both to a common data type. This process is known as casting. Sometimes you need to directly cast yourself. Consider the code below.
This code will not compile. This is because we are trying to add a number to a string. Due to the encoding scheme used for both integers and text (ASCii) the programming language needs further instructions on how to handle this. We can use a explicit cast to perform what we want.
Databases use primitive data types for its fields. A single record, therefore, is a collection of primitive data types. |