Data Types

From Mario Fan Games Galaxy Wiki
Revision as of 20:22, 17 October 2010 by RetroX (talk | contribs) (Created page with 'In programming, there are several kinds of types to describe variables. In most interpreted languages, variables can take any…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

In programming, there are several kinds of types to describe variables. In most interpreted languages, variables can take any type. In Progrmaming Languages#Compiled Languages|compiled languages]], programs have to specify what type of data is being stored so that the computer can handle it.

Integers

The most common types of variables are integers. If an integer is signed (this is the default in most languages), they can store both positive and negative numbers. If an integer is unsigned, they can store only positive numbers and zero. For more information, see the wikipedia page on it.

Integers are considered to be "primitive" types because they are calculated directly by a CPU.

Floating-point Numbers

Floating-point numbers hold rational numbers, or numbers that contain a decimal point. They're called floating-point numbers because the decimal point "floats" to a different decimal position. For example, 10 and 100 can be represented as 1 x 101 and 1 x 102. Both of these have the same decimal value, however, the decimal point is in a different place.

Floating-point numbers are also considered to be "primitive" types.

Arrays

Arrays contain a set of variables of the same type.

Strings

Strings contain a textual string of characters. In most languages, a single character in the string is represented by an integer.

Data Structures

Data structures contain multiple variables which are bundled together. For example, you can create the data structure coord, which stores two integers for x and y.

Classes

Classes are data structures which also contain functions. Some languages allow classes that contain functions without variables.