你好,我需要在转换此值“0x00000800”后输出1即使我将此值(“0x00000800”)转换为2048,也足够了。fmt.Println(strconv.Itoa((0x00000800 >> 11) & 0x1F)) //working correctly //but my value comes as string src:= "0x00000800" fmt.Println(strconv.Itoa((src >> 11) & 0x1F)) //not working properlyhttps://gchq.github.io/CyberChef/#recipe=Convert_data_units('Bits%20(b)','Bits%20(b)')&input=MHgwMDAwMDgwMAhttps://play.golang.org/p/Sb39Ihxi3Kx
1 回答
慕尼黑5688855
TA贡献1848条经验 获得超2个赞
伊托阿不是你要找的
package main
import (
"fmt"
"strconv"
)
func main() {
fmt.Println(strconv.Itoa((0x00000800 >> 11) & 0x1F)) //working correctly
//but my value comes as string
src := "0x00000800"
// src[2:] removes 0x
// base 16 hexadecimal
// bit size of int to convert to
fmt.Println(strconv.ParseInt(src[2:], 16, 64))
}
- 1 回答
- 0 关注
- 88 浏览
添加回答
举报
0/150
提交
取消