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 134 views
1 answer 144 views
1 answer 151 views
1 answer 113 views
1 answer 130 views
1 answer 109 views
...