aboutsummaryrefslogtreecommitdiffstats
path: root/calc.go
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2023-07-29 16:37:16 -0230
committerSam Anthony <sam@samanthony.xyz>2023-07-29 16:37:16 -0230
commitc45883174aa26f9032f2c35867149971bf019525 (patch)
treeca15fe9ddfea58c8e862e83f3cfa51edd4ceb92f /calc.go
parent0f33f929104263a72ec386474658761a70cca90d (diff)
downloadpfc-c45883174aa26f9032f2c35867149971bf019525.zip
limit width of windowv1.0.1
Diffstat (limited to 'calc.go')
-rw-r--r--calc.go11
1 files changed, 4 insertions, 7 deletions
diff --git a/calc.go b/calc.go
index 4eab368..e6897fe 100644
--- a/calc.go
+++ b/calc.go
@@ -1,9 +1,6 @@
package main
-import (
- "strconv"
- "strings"
-)
+import "strconv"
type AngleMode bool
@@ -36,7 +33,7 @@ func (c *Calculator) swap() {
c.stack.push(f)
}
if st != nil {
- c.buf = strings.TrimSpace(printNum(*st))
+ c.buf = printNum(*st)
} else {
c.buf = ""
}
@@ -46,9 +43,9 @@ func (c *Calculator) swap() {
// stack, if any.
func (c *Calculator) negate() {
if con := parseConstant(c.buf); con != nil {
- c.buf = strings.TrimSpace(printNum(-*con))
+ c.buf = printNum(-*con)
} else if f, err := strconv.ParseFloat(c.buf, 64); err == nil {
- c.buf = strings.TrimSpace(printNum(-f))
+ c.buf = printNum(-f)
} else if len(c.buf) == 0 && len(c.stack) > 0 {
c.stack[len(c.stack)-1] = -c.stack[len(c.stack)-1]
}