Skip to content

Commit bc92c88

Browse files
committed
Fewer digits on the output, only digits before comma are counted
1 parent 8e48e02 commit bc92c88

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

app/src/main/java/com/example/kalkulator/utils/CalculatorHandler.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class CalculatorHandler
1919
public static final String MINUS_NAN = "-NaN";
2020
public static final String NAN = "NaN";
2121
public static final int VALUE_TEXT_VIEW_MAX_SIZE = 10;
22-
public static final int OUTPUT_MAX_SIZE = 20;
22+
public static final int OUTPUT_MAX_SIZE = 15;
2323
public static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#.##########");
2424
public static final int VIBRATION_DURATION_MS = 8;
2525
public static final int VIBRATION_AMPLITUDE = 100;
@@ -71,7 +71,15 @@ public static boolean isOutputTooLong(String formattedOutput)
7171

7272
for (char c : formattedOutput.toCharArray())
7373
{
74-
digitsInOutput += Character.isDigit(c) ? 1 : 0;
74+
// only count the digits before a comma
75+
if (c == ',')
76+
{
77+
break;
78+
}
79+
else
80+
{
81+
digitsInOutput += Character.isDigit(c) ? 1 : 0;
82+
}
7583
}
7684

7785
System.out.println("digits in output: " + digitsInOutput);

0 commit comments

Comments
 (0)