> For the complete documentation index, see [llms.txt](https://gessadavide.gitbook.io/yallo-lang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gessadavide.gitbook.io/yallo-lang/docs/types/untitled.md).

# Base Types

## Numerical (nat, int, timestamp, mutez)

### Nat

Nat type represents natural numbers (positive integers U { 0 }); a nat literal should be always followed by an *n.*

```c
const a: nat = 12n;
```

A nat value can be converted to *int* type using the *int(nat)* builtin function:

```c
const b: int = int(12n);
```

### Int

Int type represents integer numbers; we define an *int*:

```c
const a: int = 12;
```

We can check if the *int* is a *nat*:

```c
const b1: bool = isNat(12);  // true
const b2: bool = isNat(-12); // false
```

Transform an *int* to a *nat*:

```c
const c: nat = abs(-12);
```

And negate a *nat* or *int* (the result type is always an int):

```c
const d1: int = neg(12n);   // = -12
const d2: int = neg(-12);   // = 12
```

### Mutez

Mutez type represents a tez amount. A mutez literal si preceeded by mtz or tz; 1000000mtz = 1tz.

```c
const a: mutez = 1tz;
const b: mutez = 1mtz;
```

### Timestamp

Timestamp type represent an unix timestamp (seconds since Jan 01 1970).

```c
const a: timestamp = 1593765393;
```

We also have an helper called *Timestamp.duration* which produces an int value for a duration.&#x20;

```c
const a: int = Timestamp.duration (45, "seconds");
const b: int = Timestamp.duration (45, "minutes");
const c: int = Timestamp.duration (45, "hours");
const d: int = Timestamp.duration (45, "days");
const e: int = Timestamp.duration (45, "weeks");
const f: int = Timestamp.duration (45, "years");
```

We can get the current *timestamp* using the *now* function:

```c
const a: timestamp = Timestamp.now();
const b: timestamp = a + Timestamp.duration(1, "days");
```

## Bool

Bool type represents a boolean, which has two possible values: *true* and *false.*

```cpp
const aTrue: bool = true;
const aFalse: bool = false;
```

## Enum

Enum type are unit variants; low level are represented as nat, so they are comparable (only for equality).

```cpp
type anEnum = enum (Started | Stopped);

let av: anEnum = anEnum#Started;
let b: bool = av = anEnum#Stopped; // false
```

## String

String are sequences of characters.

```cpp
let a: string = "Hello World";
```

We can get the length of a string with *size:*

```cpp
let b: nat = a.size();
```

And get a *slice*:

```cpp
let c: string = a.slice(1, 5);
```

## Bytes

Bytes are sequences of bytes. Like strings you can get the *length* and a *slice*.&#x20;

```cpp
let a: bytes = "...";
let b: nat = a.size();
let c: bytes = a.slice(1, 5);
```

Bytes type is useful for encoding/decoding Michelson data using *pack* and *unpack*:

```cpp
let n: nat = 12n;
let a: bytes = Bytes.pack (n); // pack a nat
let b: nat option = (Bytes.unpack (a): nat option);

let c: bool = n = (Option.getSome(b));
```

## Unit

The unit type is a type which has only a value *Unit.*

```cpp
const a: unit = Unit;
```
