Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cvt.Int64转换出错 #7

Closed
klarkxy opened this issue Sep 2, 2022 · 4 comments
Closed

cvt.Int64转换出错 #7

klarkxy opened this issue Sep 2, 2022 · 4 comments

Comments

@klarkxy
Copy link

klarkxy commented Sep 2, 2022

package main

import (
	"fmt"

	"github.com/shockerli/cvt"
)

func main() {
	fmt.Print("7138826985640367621", "\n")
	fmt.Print(cvt.Int64("7138826985640367621"), "\n")
}

输出

7138826985640367621
7138826985640368128
@klarkxy
Copy link
Author

klarkxy commented Sep 2, 2022

image

@klarkxy
Copy link
Author

klarkxy commented Sep 2, 2022

改成strconv.ParseInt(vv, 10, 64)解决问题

@shockerli
Copy link
Owner

shockerli commented Sep 3, 2022

感谢您的反馈。

原转换方案为了兼容浮点数字符串也能转换成数字,故采用了ParseFloat作为中间转换,如:12.0 => 12

故丢失了精度。最新提交,已修复此问题。

@shockerli
Copy link
Owner

已于 v0.2.2 修复

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants