---
title: "Rounding and random numbers"
description: "TapHome scripting rounding and random numbers: ROUND halves away from zero, round to one decimal place, CEIL and FLOOR to a multiple, RAND and RANDINT random values."
url: "https://taphome.com/en/docs/script/rounding-and-random/"
language: en
lastmod: 2026-11-06
generator: hugo
ai:
  topics: ["mathematical-functions","rounding","random-numbers","scripting-language"]
  questions: ["How to round a number in TapHome script?","How do I round a value to one decimal place in a TapHome script?","How do I round up or down to a multiple with CEIL and FLOOR?","How to generate a random number in TapHome?","How do I generate a random integer in TapHome?"]
---

# Rounding and random numbers

TapHome script functions for rounding and random numbers — ROUND, CEIL and FLOOR with significance, RAND and RANDINT.

Last updated: 2026-11-06

Functions that round a number or produce a random one. All of them return a `double`. Other arithmetic functions are on [Mathematical functions](https://taphome.com/en/docs/script/mathematical-functions/).

## ROUND

`ROUND` rounds a number to the nearest whole number; a half is rounded away from zero (`2.5` to `3`, `-2.5` to `-3`).

```text
ROUND(number)
```

**Remarks** — `ROUND` has no argument for decimal places. To round to one decimal place, multiply by 10, round and divide by 10; use 100 for two places.

**Example**

```taphome
# below one half: rounds down
ROUND(2.49);
# Result: 2
# a half rounds away from zero
ROUND(2.5);
# Result: 3
# a negative half rounds to -3
ROUND(-2.5);
# Result: -3
# one decimal place: x10, round, /10
ROUND(21.46 * 10) / 10;
# Result: 21.5
```

## CEIL

`CEIL` rounds a number up to the next whole number, or to the next multiple of `significance` when it is given.

```text
CEIL(number)
CEIL(number, significance)
```

**Parameters**

| Name | Type | Description |
|---|---|---|
| `number` | number | Value to round. |
| `significance` | number, optional | Multiple to round to, for example `0.5` or `5`. Default `1`. It must not be `0`, and it must not be negative when `number` is positive. |

**Remarks** — With a positive `significance` the result moves towards plus infinity, so a negative number moves towards zero (`CEIL(-22.25, 1)` is `-22`). With a negative `significance` a negative number moves away from zero (`CEIL(-22.25, -1)` is `-23`).

**Example**

| Call | Result |
|---|---|
| `CEIL(22.25)` | `23` |
| `CEIL(22.25, 0.5)` | `22.5` |
| `CEIL(22.25, 5)` | `25` |
| `CEIL(-22.25)` | `-22` |
| `CEIL(-22.25, -1)` | `-23` |
| `CEIL(-22.25, -5)` | `-25` |

**Errors** — *Significance cannot be 0.*; *Significance cannot be negative value if a number is a positive value.*

## FLOOR

`FLOOR` rounds a number down to the previous whole number, or to the previous multiple of `significance` when it is given.

```text
FLOOR(number)
FLOOR(number, significance)
```

**Parameters** and **Errors** are the same as for [CEIL](https://taphome.com/en/docs/script/rounding-and-random/#ceil).

**Remarks** — With a positive `significance` the result moves towards minus infinity, so a negative number moves away from zero (`FLOOR(-22.25, 1)` is `-23`). With a negative `significance` a negative number moves towards zero (`FLOOR(-22.25, -1)` is `-22`).

**Example**

| Call | Result |
|---|---|
| `FLOOR(22.25)` | `22` |
| `FLOOR(22.25, 0.5)` | `22` |
| `FLOOR(17, 5)` | `15` |
| `FLOOR(-22.25)` | `-23` |
| `FLOOR(-22.25, -1)` | `-22` |
| `FLOOR(-22.25, -5)` | `-20` |

A whole-number division, for example days from seconds:

```taphome
VAR uptime := 200000;
FLOOR(uptime / 86400);
# Result: 2
```

## RAND

`RAND` returns a random number from 0 up to, but not including, 1; every call gives a new value.

```text
RAND()
```

**Example**

```taphome
RAND() * 100;
# Result: a random number from 0 to just below 100
```

## RANDINT

`RANDINT` returns a random whole number from `min` up to, but not including, `max`.

```text
RANDINT(min, max)
```

**Returns** — `double` holding a whole number. Use whole numbers for both limits: with a decimal `min` the result can be lower than `min`.

**Remarks** — `RAND` and `RANDINT` are not cryptographically secure. For a key, an `iv` or a nonce use [RANDBYTES](https://taphome.com/en/docs/script/encryption-and-hashes/#randbytes).

**Example**

```taphome
RANDINT(1, 7);
# Result: 1, 2, 3, 4, 5 or 6
```
