-
- Downloads
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.
Showing
- doc/src/sgml/func.sgml 13 additions, 1 deletiondoc/src/sgml/func.sgml
- src/backend/utils/adt/numeric.c 348 additions, 26 deletionssrc/backend/utils/adt/numeric.c
- src/include/catalog/catversion.h 2 additions, 2 deletionssrc/include/catalog/catversion.h
- src/include/catalog/pg_proc.h 6 additions, 2 deletionssrc/include/catalog/pg_proc.h
- src/include/utils/builtins.h 2 additions, 1 deletionsrc/include/utils/builtins.h
- src/test/regress/expected/numeric.out 81 additions, 0 deletionssrc/test/regress/expected/numeric.out
- src/test/regress/sql/numeric.sql 18 additions, 0 deletionssrc/test/regress/sql/numeric.sql
Loading
Please register or sign in to comment