From: | Barry Lind <blind(at)xythos(dot)com> |
---|---|
To: | "w(dot)winter" <w(dot)winter(at)logitags(dot)com> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: precision of numeric type |
Date: | 2002-10-29 16:53:24 |
Message-ID: | 3DBEBD04.7000503@xythos.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Wolfgang,
w.winter wrote:
> Hi,
>
> on testing our auto-configuration persistence framework ACP against
> PostgreSQL we found the following problem:
>
> I have a table with a column of type numeric(48,10). The PostgreSQL docs
> say: "The type numeric can store numbers of practically unlimited size and
> precision, while being able to store all numbers and carry out all
> calculations exactly."
This is true.
>
> I store the Double value 1212121234.5634349876 with a
> PreparedStatement.setDouble()
>
But the problem is that java Double isn't able to perform calculations
exactly. If you want exact precision you should be using the BigDecimal
datatype (and getBigDecimal/setBigDecimal). BigDecimal is the logical
java data type that corresponds to the numeric type in postgres.
thanks,
--Barry
From | Date | Subject | |
---|---|---|---|
Next Message | Barry Lind | 2002-10-29 16:55:14 | Re: DatabaseMetaData.getTables() problem |
Previous Message | Barry Lind | 2002-10-29 16:45:17 | Re: executeBatch problem |