---
title: "number"
description: "Numeric conversion and operations"
weight: 20
type: "docs"
---

The `number` function is an intrinsic (always available, no `use()` needed). It is **polymorphic** — its behavior depends on the type of the first argument.

## Conversion

### number(logical)

Convert boolean to number.

```javascript
number(true)   // 1
number(false)  // 0
```

### number(text, radix)

Parse text to number. Radix is 2-36 (default: 10).

```javascript
number("42")        // 42
number("ff", 16)    // 255
number("1010", 2)   // 10
```

### number(text, format)

Parse formatted numbers.

| Format | Description |
|--------|-------------|
| `""` | Standard decimal |
| `"u"` | Underbar separator (1_000) |
| `"d"` | Comma separator (1,000) |
| `"s"` | Space separator (1 000) |
| `"v"` | European (1.000,50) |
| `"b"` | Binary |
| `"o"` | Octal |
| `"h"` | Hexadecimal |
| `"j"` | JavaScript style (0x, 0o, 0b prefixes) |

```javascript
number("1,000", "d")    // 1000
number("0xff", "j")     // 255
```

## Methods

### abs(n)

Absolute value.

```javascript
abs(-5)   // 5
abs(5)    // 5
```

### sign(n)

Returns -1, 0, or 1.

```javascript
sign(-5)  // -1
sign(0)   // 0
sign(5)   // 1
```

### floor(n, place)

Round down.

```javascript
floor(4.9)      // 4
floor(4.567, 2) // 4.56
```

### ceiling(n, place)

Round up.

```javascript
ceiling(4.1)      // 5
ceiling(4.123, 2) // 4.13
```

### round(n, place)

Round to nearest.

```javascript
round(4.5)      // 5
round(4.567, 2) // 4.57
```

### trunc(n, place)

Truncate toward zero.

```javascript
trunc(4.9)   // 4
trunc(-4.9)  // -4
```

### whole(n)

Get the integer part.

```javascript
whole(4.9)   // 4
whole(-4.9)  // -4
```

### fraction(n)

Get the fractional part.

```javascript
fraction(4.75)  // 0.75
```

### min(a, b)

Return the smaller of two numbers.

```javascript
min(3, 5)  // 3
```

### max(a, b)

Return the larger of two numbers.

```javascript
max(3, 5)  // 5
```

### remainder(dividend, divisor)

Compute remainder.

```javascript
remainder(17, 5)  // 2
```
