diff options
author | Mikkel Oscar Lyderik <mikkeloscar@gmail.com> | 2016-01-24 02:59:58 +0100 |
---|---|---|
committer | Mikkel Oscar Lyderik <mikkeloscar@gmail.com> | 2016-01-24 02:59:58 +0100 |
commit | 2707be71994c015b873c4879e8ebb41fb511cbf3 (patch) | |
tree | cea24eaba6b570774899390e8b4bdc0ce32a71f5 /common | |
parent | Merge pull request #457 from mikkeloscar/move-view-fix (diff) | |
download | sway-2707be71994c015b873c4879e8ebb41fb511cbf3.tar.gz sway-2707be71994c015b873c4879e8ebb41fb511cbf3.tar.zst sway-2707be71994c015b873c4879e8ebb41fb511cbf3.zip |
use log10 in numlen
Diffstat (limited to 'common')
-rw-r--r-- | common/util.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/common/util.c b/common/util.c index 243f90a8..25a3e861 100644 --- a/common/util.c +++ b/common/util.c | |||
@@ -1,3 +1,5 @@ | |||
1 | #include <math.h> | ||
2 | |||
1 | #include "util.h" | 3 | #include "util.h" |
2 | 4 | ||
3 | int wrap(int i, int max) { | 5 | int wrap(int i, int max) { |
@@ -5,13 +7,10 @@ int wrap(int i, int max) { | |||
5 | } | 7 | } |
6 | 8 | ||
7 | int numlen(int n) { | 9 | int numlen(int n) { |
8 | if (n >= 1000000) return 7; | 10 | if (n == 0) { |
9 | if (n >= 100000) return 6; | 11 | return n; |
10 | if (n >= 10000) return 5; | 12 | } |
11 | if (n >= 1000) return 4; | 13 | return log10(n) + 1; |
12 | if (n >= 100) return 3; | ||
13 | if (n >= 10) return 2; | ||
14 | return 1; | ||
15 | } | 14 | } |
16 | 15 | ||
17 | static struct modifier_key { | 16 | static struct modifier_key { |