First of all , thanks a ton for patiently answering my questions :-)
I want to clarify this suppose i do this double d = resultSet.getDouble(someFieldName);
and in the Db the number is 999999999999999.999 (15,3)
you mean to say the double will not be able to hold the precision
I thought that double has a much higher range .
The problem for me is that the code which retreives from the Db belongs to another project and i cant ask them to change code. Morover the field is a double field in informix
Suppose i have access to this double and then i use the BigDecimal part is there no way to maintain accuracy and print the value as 999999999999999.999
Also note that in my sample code i am converting the double to string then using it in constructor of bigdecimal does even this not make a difference
Joined: Jan 29, 2003
A Java double number has three parts: 52 bits of "significand" and 11 bits of "exponent" and a 1 bit sign. When a number is too big for the 52 bit significand the exponent kicks in to multiply (or divide) the significand by 10, 100, 1000 etc. Any time you multiply you get zeros for the rightmost digits, losing some precision. In most domains (except Bill Gates' checking account!) when you have a number in the trillions, the ones don't make that much difference.
I have no idea what the structure of an Informix double is but it's probably similar. If so, the precision you are looking for may simply not be there.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi