如何在 Go 中将一长串数字(50 位)转换为整数?
我得到以下代码的输出:
number = 2147483647
err = strconv.ParseInt:解析“37107287533902102798797998220837590246510135740250”:值超出范围
它似乎只能将数字转换为 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, "\n")
for i, line := range lines {
fmt.Printf("%d: %s\n", i, line)
number, err := strconv.Atoi(line)
fmt.Println("number = ", number)
fmt.Println("err = ", err)
}
}