I am trying to find the length of the double let say (123456789123456789123456789.1234567890) which is dynamic. I am trying to use the DecimalFormat class to find the length of this double as below.
double value = 123456789123456789123456789.1234567890; DecimalFormat formatter = new DecimalFormat("####,####,####"); String str = formatter.format(value); int strLen = str.length();
It would be great, if any one help me to find out the format which can be used to calculate the length of the double which is dynamic.
Many thanks in advance!
Joined: Oct 30, 2001
The length is 64 bits, of course!
I guess what you want is the number of characters in a decimal representation of the binary floating-point double-precision number. Unfortunately, such things are dubious, because it's all inexact.
Perhaps, though, all you want is the number of characters in Java's default way of outputting a particular double. In that case, you can just convert the double to a Double, do toString() on it and get the length() of the String.
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.<br /> <br />#:^P