On Thu, May 26, 2005 at 08:56:34AM -0400, Paul Tillotson wrote:
> Tom Lane wrote:
>
> >Paul Tillotson <[EMAIL PROTECTED]> writes:
> In other words, no arbitrary number of extra decimal places when calling
> div_var() will be always sufficient to prevent rounding up at some other
> decimal place.
No, an arbitrary number won't do. I found I could make it work by
adding as much extra decimals as digits in the divisor. At least it
worked for these test cases I made up. (Attached)
> >I cannot believe that that won't create problems at least as bad as it
> >solves. Have you even tried the regression tests on this?
> <sheepish grin> No. Can you tell me how to do that?
make installcheck in src/test/regress
--
Alvaro Herrera (<alvherre[a]surnet.cl>)
"C�mo ponemos nuestros dedos en la arcilla del otro. Eso es la amistad; jugar
al alfarero y ver qu� formas se pueden sacar del otro" (C. Halloway en
La Feria de las Tinieblas, R. Bradbury)
drop table modtest;
create table modtest (name text, arg1 numeric, arg2 numeric);
copy modtest from stdin;
uno 4385200147210375820 123
dos 12345678901234567934 123
tres 539379618106876228181 122
cuatro 539379618106876228319 123
cinco 66343693027145776082375 123
seis 8160274242338930458142210 123
siete 1003713731807688446351500562 123
ocho 123456789012345678901234567895 123
nueve 1234567890123456789012345678901234567856 123
diez 12345678901234567890123456789012345678901234567817 123
once 123456789012345678901234567890123456789012345678901234567901 123
doce 1234567890123456789012345678901234567890123456789012345678901234567859
12
trece 1234567890123456789012345678901234567890123456789012345678901234567862
123
catorce 1234567890123456789012345678901234567890123456789012345678901234566713
1234
quince
1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567321
1234
dieciseis
1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234558889
12345
\.
select name, arg1 % arg2 from modtest;
\echo 0
select name, arg2, arg1 % arg2::numeric(10,0), log(arg2)::int from modtest;
\echo 1
select name, arg2, arg1 % arg2::numeric(10,1), log(arg2)::int from modtest;
\echo 2
select name, arg2, arg1 % arg2::numeric(10,2), log(arg2)::int from modtest;
\echo 3
select name, arg2, arg1 % arg2::numeric(10,3), log(arg2)::int from modtest;
\echo 4
select name, arg2, arg1 % arg2::numeric(10,4), log(arg2)::int from modtest;
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faq