package main
import (
"fmt"
"github.com/gogf/gf/v2/util/gconv"
)
func main() {
i := 123.456
fmt.Printf("%10s %v\n", "Int:", gconv.Int(i))
fmt.Printf("%10s %v\n", "Int8:", gconv.Int8(i))
fmt.Printf("%10s %v\n", "Int16:", gconv.Int16(i))
fmt.Printf("%10s %v\n", "Int32:", gconv.Int32(i))
fmt.Printf("%10s %v\n", "Int64:", gconv.Int64(i))
fmt.Printf("%10s %v\n", "Uint:", gconv.Uint(i))
fmt.Printf("%10s %v\n", "Uint8:", gconv.Uint8(i))
fmt.Printf("%10s %v\n", "Uint16:", gconv.Uint16(i))
fmt.Printf("%10s %v\n", "Uint32:", gconv.Uint32(i))
fmt.Printf("%10s %v\n", "Uint64:", gconv.Uint64(i))
fmt.Printf("%10s %v\n", "Float32:", gconv.Float32(i))
fmt.Printf("%10s %v\n", "Float64:", gconv.Float64(i))
fmt.Printf("%10s %v\n", "Bool:", gconv.Bool(i))
fmt.Printf("%10s %v\n", "String:", gconv.String(i))
fmt.Printf("%10s %v\n", "Bytes:", gconv.Bytes(i))
fmt.Printf("%10s %v\n", "Strings:", gconv.Strings(i))
fmt.Printf("%10s %v\n", "Ints:", gconv.Ints(i))
fmt.Printf("%10s %v\n", "Floats:", gconv.Floats(i))
fmt.Printf("%10s %v\n", "Interfaces:", gconv.Interfaces(i))
}
6 Comments
AmarsDing
gconv
对float
类型是否可以加入:保留几位小数输出的可选参数对int类型是否可以加入:前置补零(补充元素为传参)的格式化输出
Thomson
类型转换跟格式化打印输出没有关系
杨率帅
请问,在将
int int64 int16 int32
转换为bytes
时,使用的是 大端模式 还是 小端模式?海亮
小端
https://github.com/gogf/gf/blob/093034acd1b20feddcc1cebeb9febfd45353ca2d/encoding/gbinary/gbinary.go#L12
杨率帅
谢谢
钱波
字符串转slice的int64位的方法是怎么转的呀?
比如:字符串:"41,40,42,43"
转为