# Terraform Numeric Functions Cheatsheet

This is a recap of Terraform numeric functions, to read the updated and complete documentation visit the [hashicorp page](https://www.terraform.io/docs/configuration/functions.html).

### min

`min(set number) number`

Given a set of numbers (or a compatible structure), this function returns the smallest one

```plaintext
>min(1,55,127,4,10)
1

>min([55,4,10]...)
4
```

### max

`max(set number) number`

Given a set of numbers (or a compatible structure), this function returns the biggest one

```plaintext
>max(1,55,127,4,10)
127

>max([55,4,10]...)
55
```

### parseint

`parseint(string stringNumber, number base) number`

Given a string representation of a number and its base, this function will return an integer.  
The base must be between 2 and 62 inclusive.

```plaintext
>parseint("25", 10)
25

>parseint("1FF", 16)
511

>parseint("111", 2)
7
```

### floor

`floor(number num)`

This function will return the closest whole number that is less or equal to the input number. The input number can be decimal.

```plaintext
>floor(11.9)
11

>floor(11)
11

floor(9.1)
9
```

### ceil

`ceil(number num)`

This function will return the closest whole number that is greater or equal to the input number. The input number can be decimal.

```plaintext
>ceil(11.9)
12

>floor(11)
11

floor(9.1)
10
```

### abs

`abs(number num) number`

Given an integer number, `abs` will return its absolute value. If the input number is negative, it will be multiplied by `-1`.

```plaintext
>abs(10)
10

>abs(-10)
10

>abs(0)
0
```

### pow

`pow(number num, number elevation)`

This function will elevate the first argument `num` to the second argument `elevation`.

```plaintext
>pow(4,2)
16

>pow(3,1)
3

>pow(9,0)
1
```

### signum

`signum(number num)`

This function returns a number representing the symbol of the input number.

```plaintext
>signum(-1)
-1

>signum(1)
1

>signum(9999)
1

>signum(0)
0
```
