How to count the digits of a double value in Java

1 Answer

0 votes
public class Program
{
	public static void main(String[] args)
	{
		double d = 9812347.9085;

		String dstr = String.valueOf(d);

		int total_digits = dstr.length() - 1;

		System.out.print(total_digits);
	}
}




/*
run:
 
11
 
*/

 



answered Mar 3, 2024 by avibootz

Related questions

1 answer 124 views
1 answer 136 views
1 answer 142 views
1 answer 105 views
1 answer 121 views
1 answer 101 views
...