Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

进制转换:

//十进制转二进制 八进制 十六进制
func TestBase2(t *testing.T) {
	a := strconv.FormatInt(15, 2)
	b := strconv.FormatInt(15, 8)
	c := strconv.FormatInt(15, 10)
	d := strconv.FormatInt(15, 16)
	log.Printf("base2 = %s,base8 = %s,base10 = %s,base16 = %s", a, b, c, d)
}

output:

2022/03/23 15:05:26 base2 = 1111,base8 = 17,base10 = 15,base16 = f
--- PASS: TestBase2 (0.01s)