git://git.iain.cx/iain
/
pstop.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
v0.1.3 add support for explicit --defaults-file=xx on command line
[pstop.git]
/
lib
/
common.go
diff --git
a/lib/common.go
b/lib/common.go
index
1f21c7f
..
9d31075
100644
(file)
--- a/
lib/common.go
+++ b/
lib/common.go
@@
-11,6
+11,9
@@
import (
const (
myname = "pstop"
copyright = "Copyright (C) 2014 Simon J Mudd <sjmudd@pobox.com>"
const (
myname = "pstop"
copyright = "Copyright (C) 2014 Simon J Mudd <sjmudd@pobox.com>"
+ i_1024_2 = 1024 * 1024
+ i_1024_3 = 1024 * 1024 * 1024
+ i_1024_4 = 1024 * 1024 * 1024 * 1024
)
// myround converts this floating value to the right width etc.
)
// myround converts this floating value to the right width etc.
@@
-103,15
+106,15
@@
func FormatAmount(amount uint64) string {
return strconv.Itoa(int(amount))
}
return strconv.Itoa(int(amount))
}
- if amount >
(1024 * 1024 * 1024 * 1024)
{
+ if amount >
i_1024_4
{
suffix = "P"
suffix = "P"
- decimal_amount = float64(amount) /
1024 / 1024 / 1024 / 102
4
- } else if amount >
(1024 * 1024 * 1024)
{
+ decimal_amount = float64(amount) /
i_1024_
4
+ } else if amount >
i_1024_3
{
suffix = "G"
suffix = "G"
- decimal_amount = float64(amount) /
1024 / 1024 / 1024
- } else if amount >
(1024 * 1024)
{
+ decimal_amount = float64(amount) /
i_1024_3
+ } else if amount >
i_1024_2
{
suffix = "M"
suffix = "M"
- decimal_amount = float64(amount) /
1024 / 1024
+ decimal_amount = float64(amount) /
i_1024_2
} else if amount > 1024 {
suffix = "k"
decimal_amount = float64(amount) / 1024
} else if amount > 1024 {
suffix = "k"
decimal_amount = float64(amount) / 1024