Skip to content

Commit

Permalink
fix percent crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkempire78 committed Aug 15, 2022
1 parent f161cbc commit e3f73af
Showing 1 changed file with 3 additions and 0 deletions.
Expand Up @@ -282,6 +282,9 @@ class MainActivity : AppCompatActivity() {
*/
private fun getPercentString(calculation: String): String {
val percentPos = calculation.lastIndexOf('%')
if (percentPos < 1) {
return calculation
}
// find the last operator before the last %
val operatorBeforePercentPos = calculation.subSequence(0, percentPos - 1).lastIndexOfAny(charArrayOf('-', '+', '×', '÷', '('))
if (operatorBeforePercentPos < 1) {
Expand Down

0 comments on commit e3f73af

Please sign in to comment.