diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-04-04 18:45:36 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-04-04 18:45:36 +0000 |
commit | a0fad9762a22e739de69c85b51ff7a47e672732f (patch) | |
tree | 9224424c35267ba173351e4a59aea8fc2714d3c7 /doc/src | |
parent | b6f0ad4b0ed7942654a26f04ca167cd2fe3c5d41 (diff) | |
download | postgresql-a0fad9762a22e739de69c85b51ff7a47e672732f.tar.gz postgresql-a0fad9762a22e739de69c85b51ff7a47e672732f.zip |
Re-implement division for numeric values using the traditional "schoolbook"
algorithm. This is a good deal slower than our old roundoff-error-prone
code for long inputs, so we keep the old code for use in the transcendental
functions, where everything is approximate anyway. Also create a
user-accessible function div(numeric, numeric) to provide access to the
exact result of trunc(x/y) --- since the regular numeric / operator will
round off its result, simply computing that expression in SQL doesn't
reliably give the desired answer. This fixes bug #3387 and various related
corner cases, and improves the usefulness of PG for high-precision integer
arithmetic.
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/func.sgml | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 1fa0fc6c2a3..0811a282db2 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -1,4 +1,4 @@ -<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.426 2008/04/04 16:57:21 momjian Exp $ --> +<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.427 2008/04/04 18:45:36 tgl Exp $ --> <chapter id="functions"> <title>Functions and Operators</title> @@ -618,6 +618,9 @@ <primary>degrees</primary> </indexterm> <indexterm> + <primary>div</primary> + </indexterm> + <indexterm> <primary>exp</primary> </indexterm> <indexterm> @@ -718,6 +721,15 @@ </row> <row> + <entry><literal><function>div</function>(<parameter>y</parameter> <type>numeric</>, + <parameter>x</parameter> <type>numeric</>)</literal></entry> + <entry><type>numeric</></entry> + <entry>integer quotient of <parameter>y</parameter>/<parameter>x</parameter></entry> + <entry><literal>div(9,4)</literal></entry> + <entry><literal>2</literal></entry> + </row> + + <row> <entry><literal><function>exp</function>(<type>dp</type> or <type>numeric</type>)</literal></entry> <entry>(same as input)</entry> <entry>exponential</entry> |