From 05cbc2029d50d0c95ba862a1a967f571df2db49c Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Sun, 10 Nov 2024 17:13:01 +0000 Subject: [PATCH] add percentages! --- README.md | 1 + pretty/pretty.go | 2 ++ 2 files changed, 3 insertions(+) diff --git a/README.md b/README.md index 13a6aff..4a51be1 100644 --- a/README.md +++ b/README.md @@ -194,6 +194,7 @@ Done: To (possibly) do: +- [ ] Consider adding an understanding of percentages - [ ] With the -f command line option, the program doesn't read from stdin after finishing reading the file - [ ] Add functions. Now easier to do with an explicit representation of the stakc - [ ] Think about how to draw a histogram from samples diff --git a/pretty/pretty.go b/pretty/pretty.go index 1546f51..3e6eb79 100644 --- a/pretty/pretty.go +++ b/pretty/pretty.go @@ -72,6 +72,8 @@ func ParseFloat(word string) (float64, error) { n := len(word) - 1 f, err := strconv.ParseFloat(word[:n], 64) switch word[n] { + case '%': + return multiplyOrPassThroughError(0.01, f, err) case 'K': return multiplyOrPassThroughError(1_000, f, err) case 'M':