打印
[实用程序源码及工具软件]

Golang语言下的inttohex()和hextoint()

[复制链接]
132|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
hotpower|  楼主 | 2023-9-18 22:10 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
//菜农HotPower[url=home.php?mod=space&uid=516618]@163.com[/url] 2019.6.21于西安雁塔菜地
func inttohex(val, size int) string { //size必须int
        fmts := "%0" + strconv.Itoa(size) + "X"//%#输出0X1234
        return fmt.Sprintf(fmts, val)
}

func hextoint(str string, size int) int {
        var result int = 0
        fmts := "%0" + strconv.Itoa(size) + "X" //%#输入0X1234
        fmt.Sscanf(str, fmts, &result)


使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:[url=http://www.21ic.com/tools/HotWC3_V1.23.html]

1460

主题

21619

帖子

506

粉丝