Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Golang number base conversion

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 ?

like image 552
Elmor Avatar asked Feb 02 '17 07:02

Elmor


People also ask

How to convert decimal to binary number in Golang?

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.

What is an octal number in Golang?

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.

What is type conversion in Golang?

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.

What is decimal number in Go language?

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.


1 Answers

package main

import (
    "fmt"
    "math/big"
)

func main() {
    fmt.Println(big.NewInt(1000000000000).Text(62))
}

Demo

like image 145
Ravi Avatar answered Sep 30 '22 10:09

Ravi