In some cases, the integer values can be represented by other than decimal representations. The conversion between these representations is easily done with the use of the strconv package.
Converting between binary, octal, decimal, and hexadecimal
How to do it...
- Open the console and create the folder chapter03/recipe06.
- Navigate to the directory.
- Create the convert.go file with the following content:
package main
import (
"fmt"
"strconv"
)
const bin = "10111"
const hex = "1A"
const oct = "12"
const dec = "10"
const floatNum = 16.123557
func main() {
// Converts binary value...