rw_int256 values can be very large, and therefore require more memory and processing power compared to smaller data types.
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:
CREATE TABLE table_name (column_name rw_int256);
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:
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.
count ( [ DISTINCT ] rw_int256 ) -> bigint
SELECT count(v) FROM t;
13
min
Returns the minimum value in a set of values.
min ( rw_int256 ) -> rw_int256
SELECT min(v) FROM t;
-100000000000000000000000000000000
max
Returns the maximum value in a set of values.
max ( rw_int256 ) -> rw_int256
SELECT max(v) FROM t;
100000000000000000000000000000000
sum
Returns the sum of all input values.
sum ( [ DISTINCT ] rw_int256 ) -> rw_int256
SELECT sum(v) FROM t;
0
avg
Returns the average (arithmetic mean) of the selected values.
avg ( [ DISTINCT ] rw_int256 ) -> double
SELECT avg(v) FROM t;
0
hex_to_int256
Converts a hexadecimal string to a 256-bit integer.