Add functions gcd() and lcm() for integer and numeric types.
Dean Rasheed <dean.a.rasheed@gmail.com>
Add functions gcd() and lcm() for integer and numeric types. These compute the greatest common divisor and least common multiple of a pair of numbers using the Euclidean algorithm. Vik Fearing, reviewed by Fabien Coelho. Discussion: https://postgr.es/m/adbd3e0b-e3f1-5bbc-21db-03caf1cef0f7@2ndquadrant.com
Files
| Path | Change | +/− |
|---|---|---|
| doc/src/sgml/func.sgml | modified | +34 −0 |
| src/backend/utils/adt/int8.c | modified | +126 −0 |
| src/backend/utils/adt/int.c | modified | +126 −0 |
| src/backend/utils/adt/numeric.c | modified | +171 −0 |
| src/include/catalog/catversion.h | modified | +1 −1 |
| src/include/catalog/pg_proc.dat | modified | +20 −0 |
| src/test/regress/expected/int4.out | modified | +46 −0 |
| src/test/regress/expected/int8.out | modified | +46 −0 |
| src/test/regress/expected/numeric.out | modified | +44 −0 |
| src/test/regress/sql/int4.sql | modified | +25 −0 |
| src/test/regress/sql/int8.sql | modified | +25 −0 |
| src/test/regress/sql/numeric.sql | modified | +25 −0 |
Documentation touched
Discussion
- Greatest Common Divisor 70 messages · 2019-12-28 → 2020-01-26