You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

26 lines
435 B

package main
import (
"fmt"
"strconv"
"strings"
"github.com/01-edu/z01"
student "../../student"
)
func ItoaBase(value, base int) string {
if base < 2 || base > 16 {
return ""
}
return strings.ToUpper(strconv.FormatInt(int64(value), base))
}
func main() {
value := z01.RandIntBetween(-1000000, 1000000)
base := z01.RandIntBetween(2, 16)
fmt.Println(student.ItoaBase(141895, 11))
fmt.Println(ItoaBase(value, base))
}