From 6cc136fcb674d8034e6e338dd95cb0741e4f4462 Mon Sep 17 00:00:00 2001 From: dustoair <107600816+dustoair@users.noreply.github.com> Date: Mon, 22 Aug 2022 19:35:48 +0800 Subject: [PATCH] % issue handle --- Application/calculator.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Application/calculator.go b/Application/calculator.go index d6f4866..64c0020 100644 --- a/Application/calculator.go +++ b/Application/calculator.go @@ -121,7 +121,7 @@ func percent(display *widget.Entry) func() { valueStr := strconv.FormatFloat(valueFloat, 'f', -1, 64) lines[len(lines)-1] = valueStr //lines[len(lines)-1] = strconv.FormatInt(-value, 10) - display.Text = strings.Join(lines, "\n") + display.Text = line + "%=" + strings.Join(lines, "\n") display.Refresh() } } @@ -146,6 +146,7 @@ func equals(display *widget.Entry) func() { line := lines[len(lines)-1] line = strings.Trim(line, "+÷×") exprLine := strings.Replace(line, "÷", "/", -1) + exprLine = strings.Replace(line, "%", "/100", -1) exprLine = strings.Replace(exprLine, "×", "*", -1) expr, err := govaluate.NewEvaluableExpression(exprLine) if err != nil {