We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e683343 commit ce5ca17Copy full SHA for ce5ca17
Maths/CountDigit.java
@@ -7,7 +7,14 @@ public static void main(String args[]){
7
System.out.print("Enter the number: ");
8
int number = sc.nextInt();
9
int digits = 0;
10
- digits = (int)Math.floor(Math.log10(number) + 1);
11
- System.out.println("The number of digits present in the number: " + digits);
+ if(number == 0)
+ {
12
+ System.out.println("The number of digits present in the number: 1");
13
+ }
14
+ else
15
16
+ digits = (int)Math.floor(Math.log10(Math.abs(number)) + 1);
17
+ System.out.println("The number of digits present in the number: " + digits);
18
19
}
20
0 commit comments