Non-decimal radices/Convert: Difference between revisions

Content added Content deleted
m (fix bare lang tag)
Line 491: Line 491:


=={{header|Go}}==
=={{header|Go}}==
<lang go>import "strconv"
<lang go>package main


import (
s := strconv.Itob(26, 16) // returns the string 1a
"fmt"
i,_ := strconv.Btoi64("1a", 16) // returns the integer 26</lang>
"math/big"
"strconv"
)

func main () {
s := strconv.FormatInt(26, 16) // returns the string "1a"
fmt.Println(s)

i, err := strconv.ParseInt("1a", 16, 64) // returns the integer (int64) 26
if err == nil {
fmt.Println(i)
}
b, ok := new(big.Int).SetString("1a", 16) // returns the big integer 26
if ok {
fmt.Println(b)
}
}</lang>


=={{header|Groovy}}==
=={{header|Groovy}}==