|
@ -4,6 +4,7 @@ import ( |
|
|
"fmt" |
|
|
"fmt" |
|
|
"math/big" |
|
|
"math/big" |
|
|
"strconv" |
|
|
"strconv" |
|
|
|
|
|
"strings" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
//字节自动转换为B/KB/MB/GB
|
|
|
//字节自动转换为B/KB/MB/GB
|
|
@ -129,3 +130,29 @@ func FloatQuo(str ...interface{}) float64 { |
|
|
ret, _ = strconv.ParseFloat(fmt.Sprintf("%."+places+"f", ret), 64) |
|
|
ret, _ = strconv.ParseFloat(fmt.Sprintf("%."+places+"f", ret), 64) |
|
|
return ret |
|
|
return ret |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 十进制转十六进制 |
|
|
|
|
|
*/ |
|
|
|
|
|
func TenToHex(ten int) string { |
|
|
|
|
|
m := 0 |
|
|
|
|
|
hex := make([]int, 0) |
|
|
|
|
|
for { |
|
|
|
|
|
m = ten % 16 |
|
|
|
|
|
ten = ten / 16 |
|
|
|
|
|
if ten == 0 { |
|
|
|
|
|
hex = append(hex, m) |
|
|
|
|
|
break |
|
|
|
|
|
} |
|
|
|
|
|
hex = append(hex, m) |
|
|
|
|
|
} |
|
|
|
|
|
hexStr := []string{} |
|
|
|
|
|
for i := len(hex) - 1; i >= 0; i-- { |
|
|
|
|
|
if hex[i] >= 10 { |
|
|
|
|
|
hexStr = append(hexStr, fmt.Sprintf("%c", 'A'+hex[i]-10)) |
|
|
|
|
|
} else { |
|
|
|
|
|
hexStr = append(hexStr, fmt.Sprintf("%d", hex[i])) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return strings.Join(hexStr, "") |
|
|
|
|
|
} |