What is the reason for maintaining separate rscale and dscale values in
numeric variables?

I am finding that this arrangement leads to some odd results, for
example this:

regression=# select (exp(ln(2.0)) - 2.0);
      ?column?
---------------------
 -0.0000000000000000
(1 row)

regression=# select (exp(ln(2.0)) - 2.0) * 100000;
      ?column?
---------------------
 -0.0000000000000010
(1 row)

The difference between rscale and dscale allows some "hidden" digits to
be carried along in an expression result, and then possibly exposed
later.  This seems pretty nonintuitive for an allegedly exact
calculational datatype.  ISTM the policy should be "what you see is what
you get" - no hidden digits.  That would mean there's no need for
separating rscale and dscale, so I'm wondering why they were put in
to begin with.

                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html

Reply via email to