> ## Documentation Index
> Fetch the complete documentation index at: https://docs.risingwave.com/llms.txt
> Use this file to discover all available pages before exploring further.

# rw_int256

<Note>
  `rw_int256` values can be very large, and therefore require more memory and processing power compared to smaller data types.
</Note>

## Overview

`rw_int256` is a custom data type that represents a signed 256-bit integer with a storage size of 32 bytes.

It is designed to handle large integer values, and can be useful in financial calculations, cryptography, and data analysis.

## Usage

You can define a column with the `rw_int256` type:

```sql theme={null}
CREATE TABLE table_name (column_name rw_int256);
```

```sql theme={null}
CREATE TABLE t (v rw_int256);
INSERT INTO t VALUES (1), (100), (10000), (100000000), (10000000000000000), ('100000000000000000000000000000000'), (0), (-1), (-100), (-10000), (-100000000), (-10000000000000000), ('-100000000000000000000000000000000');
```

## Casting

You can also convert other data types to `rw_int256`:

```sql theme={null}
cast ('0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe' AS rw_int256);
-- or
'10000000000000000' :: rw_int256;
```

Or convert `rw_int256` to `double`.

## Supported functions

### `count`

Returns the number of non-null rows.

```sql theme={null}
count ( [ DISTINCT ] rw_int256 ) -> bigint
```

```sql theme={null}
SELECT count(v) FROM t;
```

```sql theme={null}
13
```

### `min`

Returns the minimum value in a set of values.

```sql theme={null}
min ( rw_int256 ) -> rw_int256
```

```sql theme={null}
SELECT min(v) FROM t;
```

```sql theme={null}
-100000000000000000000000000000000
```

### `max`

Returns the maximum value in a set of values.

```sql theme={null}
max ( rw_int256 ) -> rw_int256
```

```sql theme={null}
SELECT max(v) FROM t;
```

```
100000000000000000000000000000000
```

### `sum`

Returns the sum of all input values.

```sql theme={null}
sum ( [ DISTINCT ] rw_int256 ) -> rw_int256
```

```sql theme={null}
SELECT sum(v) FROM t;
```

```bash theme={null}
0
```

### `avg`

Returns the average (arithmetic mean) of the selected values.

```sql theme={null}
avg ( [ DISTINCT ] rw_int256 ) -> double
```

```sql theme={null}
SELECT avg(v) FROM t;
```

```
0
```

### `hex_to_int256`

Converts a hexadecimal string to a 256-bit integer.

```sql theme={null}
hex_to_int256 ( string ) -> rw_int256
```

```sql theme={null}
SELECT hex_to_int256('0xdeadbeef');
```

```
3735928559
```

```sql theme={null}
SELECT hex_to_int256('0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01');
```

```
-255
```

### Standard deviation and variance

Returns population standard deviation, sample standard deviation, population variance, and sample variance.

```bash theme={null}
stddev_pop ( rw_int256 ) -> double -- standard deviation
stddev_samp ( rw_int256 ) -> double -- sample standard deviation
var_pop ( rw_int256 ) -> double -- population variance
var_samp ( rw_int256 ) -> double -- sample variance
```

```sql theme={null}
SELECT stddev_pop(v), stddev_samp(v), var_pop(v), var_samp(v) FROM t;
```

```bash theme={null}
       stddev_pop       |     stddev_samp      |        var_pop         |        var_samp
------------------------+----------------------+------------------------+------------------------
 3.9223227027636808e+31 | 4.08248290463863e+31 | 1.5384615384615386e+63 | 1.6666666666666666e+63
(1 row)
```
