Data types: Difference between revisions

From Computer Science Wiki
Line 7: Line 7:
Primitive data types are typically types that are built-in or basic to a language implementation.<ref>https://en.wikipedia.org/wiki/Data_type</ref>
Primitive data types are typically types that are built-in or basic to a language implementation.<ref>https://en.wikipedia.org/wiki/Data_type</ref>


== Different types of primitive types ==
== Primitive types ==


Not all languages have the same primitive data types. Please see the table below for a representative list of types:
Not all languages have the same primitive data types. Please see the table below for a representative list of types:
Line 16: Line 16:
! Data type !! Definition !! Notes
! Data type !! Definition !! Notes
|-
|-
| [[Int]] || Integer. The mathematical name for any positive or negative whole number. || This is a primitive data type
| [[Int]] || Integer. The mathematical name for any positive or negative whole number. || This is a common primitive data type
|-
|-
| [[Boolean]] || Example || Example
| [[Float]] || A float is a number that has a fractional or decimal part.  || This is a common primitive data type
|-
|-
| [[String]] || Example || Example
| [[Boolean]] || A boolean is simply true or false, and can be nothing other than true or false || This is a common primitive data type
|-
| [[String]] || A string is used to store characters, which could be text or numbers. || This is a common primitive data type
|-
|-
| [[Float]] || foo || foo
| [[Float]] || foo || foo
|-
|-
| [[Char]] || foo || foo
| [[Char]] ||Character. This data type stores one single character.  || foo
|}
|}



Revision as of 06:18, 11 May 2020

Programming[1]

Data type determines what sort of data is being stored and how it will be used by the program. In computer science and computer programming, a data type or simply type is an attribute of data which tells the compiler or interpreter how the programmer intends to use the data [2].

Data types are important in programming languages because they help the compiler or interpreter more efficiently allocate memory. Data types tells MMU that how much memory requirement it has before the program compiles. Also, the data type defines which operations can safely be performed to create, transform and use the variable in another computation.

Primitive data types are typically types that are built-in or basic to a language implementation.[3]

Primitive types[edit]

Not all languages have the same primitive data types. Please see the table below for a representative list of types:


Data type Definition Notes
Int Integer. The mathematical name for any positive or negative whole number. This is a common primitive data type
Float A float is a number that has a fractional or decimal part. This is a common primitive data type
Boolean A boolean is simply true or false, and can be nothing other than true or false This is a common primitive data type
String A string is used to store characters, which could be text or numbers. This is a common primitive data type
Float foo foo
Char Character. This data type stores one single character. foo

References[edit]