# number

The `number` function and its methods handle numeric conversion and operations.

## 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

### number.abs(n)

Absolute value.

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

### number.sign(n)

Returns -1, 0, or 1.

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

### number.floor(n, place)

Round down.

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

### number.ceiling(n, place)

Round up.

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

### number.round(n, place)

Round to nearest.

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

### number.trunc(n, place)

Truncate toward zero.

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

### number.whole(n)

Get the integer part.

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

### number.fraction(n)

Get the fractional part.

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

### number.min(...values)

Return the smallest value.

```javascript
number.min(3, 1, 4, 1, 5)  // 1
```

### number.max(...values)

Return the largest value.

```javascript
number.max(3, 1, 4, 1, 5)  // 5
```

### number.remainder(dividend, divisor)

Compute remainder.

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