您如何在 Go 中将一长串数字( 50 位数) 转换成整数?
下面是代码的输出:
number = 2147483647
err = strconv.ParseInt: parsing "37107287533902102798797998220837590246510135740250 ": value out of range
它似乎只能转换最多达2147483647的数字。
package main
import "fmt"
import "io/ioutil"
import "strings"
import "strconv"
var (
number int64
)
func main() {
fData,err := ioutil.ReadFile("one-hundred_50.txt")
if err != nil {
fmt.Println("Err is ",err)
}
strbuffer := string(fData)
lines := strings.Split(strbuffer, "
")
for i, line := range lines {
fmt.Printf("%d: %s
", i, line)
number, err := strconv.Atoi(line)
fmt.Println("number = ", number)
fmt.Println("err = ", err)
}
}