Length of double valuye

Hi,

How to identify the length of doouble value

I am getting the double value like below

123456789123456789123456789123456789.22446688

I need to find the length of this double value.

I have tried the following ways:

1)Pretty ordinary way, just converted the incoming value to String and find the length- It is giving wrong length.

2)Used NumerberFormat class like below:

double value=123456789123456123564789121.12345;

DecimalFormat format=new DecimalFormat(".");

String s =format.format(value);

s.length?will give us the length of the double including DOT except length of the digits after the decimal point.

3) If am replacing the line DecimalFormat format=new DecimalFormat ("#"); then,

s.length?will give us the length of the double excluding DOT except length of the digits after the decimal point.

4)We can able to get the length of the double value before decimal point with option 2 and 3. But, we are not able to find the length of the digits after decimal point. I tried with substring, it is also got failed.

5)Then, I have tried using the custom NumberFormat instance, it is giving the length of the double with minor deviation, we can understands that this minor difference due to custom NumberFormatting, I am not sure which format will give us the correct length of the double.

Even i tried with BigDecimal, Please some one guide us to solve the issue

Thanks in advance

[1495 byte] By [RajeshKandhasamya] at [2007-11-27 8:57:30]
# 1
length in bytes? 8.length in bits? 64length in decimal digits? Undefined, and value-dependent, and undefined for most values containing fractions. http://docs.sun.com/source/806-3568/ncg_goldberg.html
ejpa at 2007-7-12 21:22:10 > top of Java-index,Core,Core APIs...