aspose file tools
The moose likes Java in General and the fly likes double length calculation Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "double length calculation" Watch "double length calculation" New topic
Author

double length calculation

Seetharaman Palanichamy
Greenhorn

Joined: Dec 05, 2006
Posts: 2
Hello,

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!

Seera
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: double length calculation
 
Similar Threads
How to identify double length
beginner precision question
Custom MaskFormatter
How to handle DecimalFormat overflow?
DecimalFormatting to remove decimal point