Numeral Systems - Hexadecimal#
example.go
package mainimport string">"fmt"func main() {string">"comment">// fmt.Printf(string">"%d - %b - %x \n", 42, 42, 42)string">"comment">// fmt.Printf(string">"%d - %b - %#x \n", 42, 42, 42)string">"comment">// fmt.Printf(string">"%d - %b - %#X \n", 42, 42, 42)fmt.Printf(string">"%d \t %b \t %#X \n", 42, 42, 42)}
Output:
42 101010 0X2A
In the above program, the annotation verb %x formats a number in hexadecimal. For example, it represents 42 as 0X2A (base 16 format).
Integer to Hexadecimal Cheatsheet:#
%x base 16, with lower-case letters for a-f
%X base 16, with upper-case letters for A-F