Euphoria - Data Types

The data stored in memory can be of many types. For example, a person's age is stored as a numeric value and his or her address is stored as alphanumeric characters.

Euphoria has some standard types that are used to define the operations possible on them and the storage method for each of them.

Euphoria has following four standard data types −

• integer

• atom

• sequence

• object

Though there are four data types, but understanding atoms and sequences is the key to understanding Euphoria.

Euphoria integers

Euphoria integer data types store numeric values. They are declared and defined as follows −

```integer var1, var2

var1 = 1
var2 = 100
```

The variables declared with type integer must be atoms with integer values from -1073741824 to +1073741823 inclusive. You can perform exact calculations on larger integer values, up to about 15 decimal digits, but declare them as atom, rather than integer.

Euphoria atoms

All data objects in Euphoria are either atoms or sequences. An atom is a single numeric value. Atoms can have any integer or double-precision floating point value.

Euphoria atoms are declared and defined as follows −

```atom var1, var2, var3

var1 = 1000
var2 = 198.6121324234
var3 = 'E'
```

The atoms can range from approximately -1e300 to +1e300 with 15 decimal digits of accuracy. An individual character is an atom which must may be entered using single quotes. For example, all the following are legal −

```-- Following is equivalent to the atom 66 - the ASCII code for B
char = 'B'

-- Following is equivalent to the sequence {66}
sentence = "B"
```

Euphoria sequences

All data objects in Euphoria are either atoms or sequences. A sequence is a collection of numeric values which can be accessed through their index.

Sequence index starts from 1 unlike other programming languages where array index starts from 0.

Euphoria sequences are declared and defined as follows −

```sequence var1, var2, var3, var4

var1 = {2, 3, 5, 7, 11, 13, 17, 19}
var2 = {1, 2, {3, 3, 3}, 4, {5, {6}}}
var3 = {{"zara", "ali"}, 52389, 97.25}
var4 = {} -- the 0 element sequence
```

A character string is just a sequence of characters which may be entered using double quotes. For example, all the following are legal −

```word = 'word'
sentence = "ABCDEFG"
```

Character strings may be manipulated and operated upon just like any other sequences. For example the above string is entirely equivalent to the sequence −

```sentence = {65, 66, 67, 68, 69, 70, 71}
```

Euphoria Objects

This is a super data type in Euphoria which may take on any value including atoms, sequences or integers.

Euphoria objects are declared and defined as follows −

```object var1, var2, var3

var1 = {2, 3, 5, 7, 11, 13, 17, 19}
var2 = 100
var3 = 'E'
```

An object may have one of the following values −

• a sequence

• an atom

• an integer

• an integer used as a file number

• a string sequence, or single-character atom