https:\/\/ascii.cl\/conversion.htm<\/a><\/p>\n\n\n\npackage main\n\nimport \"fmt\"\n\nfunc main() {\n hexa20 := 0x14 \/\/Equivalent to 20 in decimal\n output := 10 + hexa20\n fmt.Println(output)\n}<\/code><\/pre>\n\n\n\nOutput:<\/strong><\/p>\n\n\n\n30<\/code><\/pre>\n\n\n\n<\/p>\n\n\n\n
<\/span>Octal Numbers<\/strong><\/span><\/h1>\n\n\n\nOctal numbers can be written using prefix 0<\/strong> in Go. When Go sees any number starting with 0<\/strong>, it treats it as a octal number. In the below example, we added\u00a0 024<\/strong> in octal<\/strong> to 10. 024<\/strong> in octal<\/strong> is equal to 20<\/strong> in decimal. Therefore the output will be 30<\/p>\n\n\n\npackage main\n\nimport \"fmt\"\n\nfunc main() {\n octa20 := 024 \/\/Equivalent to 20 in decimal\n output := 10 + octa20\n fmt.Println(output)\n}<\/code><\/pre>\n\n\n\nOutput:<\/strong><\/p>\n\n\n\n30<\/code><\/pre>\n\n\n\n<\/p>\n\n\n\n
<\/span>Combined Example of Octal and Hex<\/strong><\/span><\/h1>\n\n\n\nIn the below example, 0x14<\/strong> in hexa<\/strong> is added to 024<\/strong> in octa<\/strong> and 10<\/strong>. 0x14<\/strong> in hexa<\/strong> is equal to 20<\/strong> in decimal<\/strong>. 024<\/strong> in octal<\/strong> is equal to 20<\/strong> in decimal<\/strong>. Therefore the output is 50<\/p>\n\n\n\npackage main\n\nimport \"fmt\"\n\nfunc main() {\n hexa20 := 0x14 \/\/Equivalent to 20 in decimal\n \n octa20 := 024 \/\/Equivalent to 20 in decimal\n \n output := 10 + hexa20 + octa20\n fmt.Println(output)\n}<\/code><\/pre>\n\n\n\nOutput:<\/strong><\/p>\n\n\n\n50<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"Table of Contents OverviewHex NumbersOctal NumbersCombined Example of Octal and Hex Overview Hex numbers are base 16 Octal numbers are base 8 Hex Numbers Hex numbers can be written using prefix 0x…<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[1],"tags":[4,138,139],"class_list":["post-1075","post","type-post","status-publish","format-standard","hentry","category-tech","tag-golang","tag-hex","tag-octal"],"yoast_head":"\n
Hex and Octal in Golang - Welcome To Golang By Example<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n