pgmp

pgmp : Multiple Precision Arithmetic extension

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
3700
pgmp
pgmp
1.0.5
TYPE
LGPL-3.0
C
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d-r
No
Yes
No
Yes
yes
no
Relationships
See Also
numeral
unit
pguecc
pgcrypto
prefix
semver
pgpdf
pglite_fusion

missing pg14 on el pgdg repo

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXT
PGDG
1.0.5
18
17
16
15
14
pgmp-
RPM
PGDG
1.0.5
18
17
16
15
14
pgmp_$v-
DEB
PGDG
1.0.5
18
17
16
15
14
postgresql-$v-pgmp-
Linux / PGPG18PG17PG16PG15PG14
el8.x86_64
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.4
PGDG 1.0.4
el8.aarch64
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.4
PGDG 1.0.4
el9.x86_64
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.4
MISS
el9.aarch64
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.4
PGDG 1.0.4
el10.x86_64
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
el10.aarch64
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
d12.x86_64
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
d12.aarch64
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
d13.x86_64
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
d13.aarch64
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
u22.x86_64
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
u22.aarch64
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
u24.x86_64
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
u24.aarch64
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5

Source

Install

Make sure PGDG repo available:

pig repo add pgdg -u    # add pgdg repo and update cache

Install this extension with pig:

pig install pgmp;		# install via package name, for the active PG version

pig install pgmp -v 18;   # install for PG 18
pig install pgmp -v 17;   # install for PG 17
pig install pgmp -v 16;   # install for PG 16
pig install pgmp -v 15;   # install for PG 15
pig install pgmp -v 14;   # install for PG 14

Create this extension with:

CREATE EXTENSION pgmp;

Usage

pgmp: multiple precision arithmetic (GMP) for PostgreSQL

The pgmp extension integrates the GNU Multiple Precision (GMP) library into PostgreSQL, providing arbitrary-precision integer and rational number types.

CREATE EXTENSION pgmp;

Data Types

  • mpz: Arbitrary-size integers, limited only by PostgreSQL’s 1GB varlena maximum
  • mpq: Arbitrary-precision rational numbers for exact fractional arithmetic

Basic Usage

-- Arbitrary precision integers
SELECT '123456789012345678901234567890'::mpz * 2;

-- Exact rational arithmetic (no rounding)
SELECT '1'::mpq / '3'::mpq;  -- 1/3

-- Mixed arithmetic with native PostgreSQL types
SELECT 42::mpz + '100'::mpz;

Operators

Standard arithmetic operators (+, -, *, /, %) and comparison operators (=, <>, <, >, <=, >=) are supported for both mpz and mpq.

Functions

The extension exposes all GMP library functions for these types, including:

  • Prime number functions
  • Random number generation
  • Factorization
  • GCD, LCM, and other number theory functions

Index Support

Both mpz and mpq support btree and hash indexes for efficient queries and sorting.

Full documentation: https://www.varrazzo.com/pgmp/

Last updated on