I was wondering, how do you convert a base10 number from one base to another without usage of strconv
in Golang ?
Could you please give me some advice ?
We have 2 ways to convert Decimal to Binary number in Golang. Following are two ways Below program takes decimal input number from user console, stores it in variable decimal. Inbuilt Standard package strconv provides FormatInt function used to convert Decimal to Binary number.
An Octal number is a number based on the base 8 number system. It contains digits from 0 to 7. In Golang, Octal numbers are always prefixed with zero. Example octal number is 0879. Decimal Numbers are numbers that contain numbers based on base 10.
Introduction to Golang Type Conversion. In Go language, the type conversion is a way to change the data type of variable. We generally change the data from initially we defined to another type of data type for example if we have defined a variable as integer and same variable we are going to use for some other purposes.
Decimal Number are numbers which contain numbers based on base 10. Example decimal numbers are 12, 44. To understand this example, You should have following features in Go language. The below programs takes input binary number from a user console, store it in variable binary.
package main
import (
"fmt"
"math/big"
)
func main() {
fmt.Println(big.NewInt(1000000000000).Text(62))
}
Demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With