> For the complete documentation index, see [llms.txt](https://calnix.gitbook.io/eth-dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://calnix.gitbook.io/eth-dev/compendium/solidity-basics/variable-types.md).

# Variable Types

## Data types

Variables have a data type that determines the kind of value that can be stored in the variable. Solidity supports a variety of data types, including:

* Boolean: `bool`
* Integer: `int` and `uint` of various sizes
* Address: `address`
* Bytes: `bytes` and `byte`
* String: `string`
* Arrays: `array`
* Structs: `struct`
* Enumerations: `enum`

### Default values&#x20;

The concept of “undefined” or “null” values does not exist in Solidity. Newly declared variables (without assignment) always have a [default value](https://docs.soliditylang.org/en/latest/control-structures.html#default-value) dependent on its type.

* (u)int = 0
* bool = False
* string = ""

## Data Location

Solidity variables can be classified according to their **data location**.

#### Value type

A value type stores its data directly in the memory it owns. Variables of this type are **duplicated** whenever they appear in functions or assignments. A value type will maintain an **independent copy** of any duplicated variables.&#x20;

* `uint`, `int`, `address`, `bool`, `enum`, `bytes`

{% hint style="info" %}
Therefore, a change in the value of a duplicated variable will not affect the original variable.
{% endhint %}

#### Reference type

A reference type stores the address of the data’s location; acts as a pointer to a value stored elsewhere.&#x20;

If you examine the location of where the reference type was created, it will contain the pointer directing us to the actual location of the value; not the value itself.

* `mapping`, `struct`, `array`
  * string arrays, byte arrays, array members, fixed/dynamic arrays

{% hint style="info" %}

* When a reference type variable is assigned to another variable or when a reference type variable is sent as an argument to a function, EVM creates a new variable instance and copies the pointer from the original variable into the target variable.&#x20;
* This is known as passing by reference.&#x20;
* Both the variables are pointing to the same address location. Both the variables will share the same values and change committed by one is reflected in the other variable.
  {% endhint %}
