32 lines
783 B
Go
32 lines
783 B
Go
package codec
|
|
|
|
import "strconv"
|
|
|
|
func Atoi(b []byte) (int, error) {
|
|
return strconv.Atoi(BytesToString(b))
|
|
}
|
|
|
|
func ParseInt(b []byte, base int, bitSize int) (int64, error) {
|
|
return strconv.ParseInt(BytesToString(b), base, bitSize)
|
|
}
|
|
|
|
func ParseUint(b []byte, base int, bitSize int) (uint64, error) {
|
|
return strconv.ParseUint(BytesToString(b), base, bitSize)
|
|
}
|
|
|
|
func ParseFloat(b []byte, bitSize int) (float64, error) {
|
|
return strconv.ParseFloat(BytesToString(b), bitSize)
|
|
}
|
|
|
|
func UintToString(n uint64) string {
|
|
return BytesToString(strconv.AppendUint([]byte{}, n, 10))
|
|
}
|
|
|
|
func IntToString(n int64) string {
|
|
return BytesToString(strconv.AppendInt([]byte{}, n, 10))
|
|
}
|
|
|
|
func FloatToString(f float64) string {
|
|
return BytesToString(strconv.AppendFloat([]byte{}, f, 'f', -1, 64))
|
|
}
|