양수와 0인 경우 len값 1 증가 | increasing one for len when it's plus or zero
The reason for not including positive numbers separately in the condition is as follows:
Digit Calculation Logic
For positive numbers, the subsequent while loop accurately calculates the number of digits:
c
while (n)
{
n /= 10;
len++;
}
This loop counts all the digits of a positive number.
No Additional Processing Required
Positive numbers don't need to display a sign, so no additional length is necessary.
Code Efficiency
By not handling positive numbers separately, the code becomes more concise.
Special Handling for 0 and Negative Numbers
Zero and negative numbers are treated as special cases (single-digit representation for 0, negative sign for negative numbers) and are handled separately.
Therefore, the case of positive numbers is sufficiently handled by the basic logic, eliminating the need for a separate conditional statement. This makes the code more efficient and concise.