tags:

views:

1073

answers:

2

Hello,

In one of my tables in DB2, I see the column datatype as double as length 8.

How many decimals precision would this column have?

(There is one other data type DECIMAL where I can specify the length 8 and precision)

What about double?

+2  A: 

According to the DB2 reference:

Double-precision floating-point (DOUBLE or FLOAT)

A double-precision floating-point number is a 64-bit approximation of a real number. The number can be zero or can range from -1.79769E+308 to -2.225E-307, or from 2.225E-307 to 1.79769E+308.

DrJokepu
+1  A: 

And the other bit of information (compared with DrJokepu's answer) is that because it is IEEE 754 double precision, you can get about 16 (some will claim 17) decimal digits. However, be aware of all the issues of floating point accuracy. Generally, it is a bad idea to use DOUBLE for monetary quantities in accounting packages (but it might be OK for fantasy games like the US budget, where balancing isn't critical).

Jonathan Leffler
Exactly. One thing to note is that DB2 can take advantage of IBM's POWER6 servers' capability of handling decimals in hardware so if you're running DB2 on one of those systems, you should definitely use decimals.
DrJokepu
And that type is DECFLOAT - maybe with a qualifier.
Jonathan Leffler