pgratio
Extension for PostgreSQL to support rational numbers (fractions).
Installation
- Download the extension by clicking on one of the links in the “Download” section below.
- Extract the tar.zst file.
- Run “make install”.
- Use “CREATE EXTENSION pgratio;” as an SQL command to load the extension into a database. This will then provide the new data type “rational”.
Example usage
postgres=> CREATE EXTENSION pgratio;
CREATE EXTENSION
postgres=> SELECT rational(2, 3) - rational(1.2) AS result;
result
--------
-8/15
(1 row)
Documentation
Refer to the README.html file in the packages below for further documentation.
Download
Changes
- 2025-10-23: Version 0.2
- Fix bug due to returning pointer to static memory in case of 0::RATIONAL (caused invalid pfree on zero rationals in array_agg for example)
- Properly zero allocated memory to ensure binary equality on certain (hypothetical) platforms
- 2024-12-23: Initial release of version 0.1