---
title: Math functions
slug: analytics/docs/math-functions
docTags: 
createdAt: 2026-07-20T15:45:12.674Z
---

You can use arithmetic math functions in NetScript in Optimizely Analytics.

## Basic operations

This section lists the basic math operations you can perform using NetScript.

### number + number

Returns the sum of the inputs.

**Function**:

```auto
number + number
```

**Data type**: number

**Example**:

```auto
5 + 7
```

**Result**:

```auto
12
```

### number - number

Returns the difference between the inputs.

**Function**:

```auto
number - number
```

**Data type**: number

**Example**:

```auto
13-10
```

**Result**:

```auto
3
```

### number \* number

Returns the product of the inputs.

**Function**:

```auto
number * number
```

**Data type**: number

**Example**:

```auto
7 * 8
```

**Result**:

```auto
56
```

### number / number

Returns the division of the inputs.

**Function**:

```auto
number / number
```

**Data type**: number

**Example**:

```auto
84 / 4
```

**Result**:

```auto
21
```

### number ^ number

Returns number1 raised to the power of number2.

**Function**:

```auto
number ^ number
```

**Data type**: number

**Example**:

```auto
2 ^ 9
```

**Result**:

```auto
512
```

## Advanced operations

This section lists the advanced math operations you can perform using NetScript.

### abs(number)

Returns the absolute value of a numeric expression.

**Function**:

```auto
abs(number)
```

**Data type**: number

**Example**:

```auto
abs(-2)
```

**Result**:

```auto
2
```

### floor(number)

Rounds the number down to the nearest integer.

**Function**:

```auto
floor(number)
```

**Data type**: number

**Example**:

```auto
floor(17.36)
```

**Result**:

```auto
17
```

### round(number\[, N])

Rounds the number to the given precision (N), which is 0 by default. Precision value can be positive or negative and indicates the number of decimal places displayed in the rounded number.

**Function**:

```auto
round(number[, <N>])
```

**Data type**: number

**Example**:

```auto
round(23.45)
round(23.45, 0)
round(23.45, 1)
round(23.45, -1)
```

**Result**:

```auto
23
23
23.5
20
```

### truncate(number\[, N])

Rounds the number *down* to the given precision (N), which is 0 by default.

**Function**:

```auto
truncate(number[, <N>])
```

**Data type**: number

**Example**:

```auto
truncate(23.45)
truncate(23.45, 0)
truncate(23.45, 1)
truncate(23.45, -1)
```

**Result**:

```auto
23
23
23.4
20
```

### sqrt(number)

Returns the square root (full-precision decimal) of the input.

**Function**:

```auto
sqrt(number)
```

**Data type**: number

**Example**:

```auto
sqrt(64)
```

**Result**:

```auto
8
```

### least(number(, number)\*)

Returns whichever number has the smallest value.

**Function**:

```auto
least(number(, number)*)
```

**Data type**: number

**Example**:

```auto
least(7(, 23)*)
```

**Result**:

```auto
7
```

### greatest(number(, number)\*)

Returns whichever number has the largest value.

**Function**:

```auto
greatest(number(, number)*)
```

**Data type**: number

**Example**:

```auto
greatest(7(, 23)*)
```

**Result**:

```auto
23
```
