I have come across many sample code whenever we try to convert string to int we use :
parseValue, err := strconv.ParseInt(value, 10, 64)
So the code above ParseInt()
has three arguments. from the documentation code :
func ParseInt(s string, base int, bitSize int) (i int64, err error) {
I tried to understand the base int
here so I change the value from 0 to 16. PlayGolang.
The result is ok when the input are 0
and 10
. Number other that 0
and 10
are panic. I still confused and not understand. Can someone explain what base
is used for in ParseInt()
?