Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita0fad97

Browse files
committed
Re-implement division for numeric values using the traditional "schoolbook"
algorithm. This is a good deal slower than our old roundoff-error-pronecode for long inputs, so we keep the old code for use in the transcendentalfunctions, where everything is approximate anyway. Also create auser-accessible function div(numeric, numeric) to provide access to theexact result of trunc(x/y) --- since the regular numeric / operator willround off its result, simply computing that expression in SQL doesn'treliably give the desired answer. This fixes bug #3387 and various relatedcorner cases, and improves the usefulness of PG for high-precision integerarithmetic.
1 parentb6f0ad4 commita0fad97

File tree

7 files changed

+470
-32
lines changed

7 files changed

+470
-32
lines changed

‎doc/src/sgml/func.sgml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.426 2008/04/0416:57:21 momjian Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.427 2008/04/0418:45:36 tgl Exp $ -->
22

33
<chapter id="functions">
44
<title>Functions and Operators</title>
@@ -617,6 +617,9 @@
617617
<indexterm>
618618
<primary>degrees</primary>
619619
</indexterm>
620+
<indexterm>
621+
<primary>div</primary>
622+
</indexterm>
620623
<indexterm>
621624
<primary>exp</primary>
622625
</indexterm>
@@ -717,6 +720,15 @@
717720
<entry><literal>28.6478897565412</literal></entry>
718721
</row>
719722

723+
<row>
724+
<entry><literal><function>div</function>(<parameter>y</parameter> <type>numeric</>,
725+
<parameter>x</parameter> <type>numeric</>)</literal></entry>
726+
<entry><type>numeric</></entry>
727+
<entry>integer quotient of <parameter>y</parameter>/<parameter>x</parameter></entry>
728+
<entry><literal>div(9,4)</literal></entry>
729+
<entry><literal>2</literal></entry>
730+
</row>
731+
720732
<row>
721733
<entry><literal><function>exp</function>(<type>dp</type> or <type>numeric</type>)</literal></entry>
722734
<entry>(same as input)</entry>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp