db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthias Ohlemeyer <matthias.ohleme...@web.de>
Subject Bug in division operator with numeric operands?
Date Mon, 20 Mar 2006 19:55:47 GMT
Hi,

I've been trying to port a relatively complex application from Oracle to
Derby for quite a while now, but it seems like I've hit a road block
now.

Can somebody explain the following behaviour? I copied the following
input-output sequence from ij:

CREATE TABLE t (d1 DOUBLE, d2 DOUBLE, n1 NUMERIC(31,11), n2
NUMERIC(31,11));
INSERT INTO t VALUES (1.5, 2.5, 1.5, 2.5);
SELECT d1/d2, n1/n2, n1*(1.0/n2) FROM t;

1           |2                 |3

----------------------------------------------------------------
0.6         |0                 |0.600000000000000000000000000000

1 row selected

All three result columns should represent 1.5/2.5=0.6.

Column 1 has the result I expected, but

a) why is the result of column 2 zero? The source columns contain the
same values as for column1, only represented as NUMERIC(31,11) instead
of DOUBLE.

b) why does column 3 show the right result? It is numerically equivalent
to column 2: n1/n2 = n1*(1.0/n2) (?!)

BTW: If I replace one of the column names with a constant I always get
correct results.

There is no way for me to switch from NUMERIC to DOUBLE because I need
the exact precision calculation.

Any hint is appreciated! Could this be a bug?

Matthias


Mime
View raw message