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

compatibility with strconv.ParseInt #67

Open
yuzhichang opened this issue May 16, 2021 · 0 comments
Open

compatibility with strconv.ParseInt #67

yuzhichang opened this issue May 16, 2021 · 0 comments

Comments

@yuzhichang
Copy link

yuzhichang commented May 16, 2021

The strconv.ParseInt in Golang std lib

  • has syntax check and return an error if s is empty or contains invalid digits.
  • has range check and return the the closest number among the range if overflow.
// The errors that ParseInt returns have concrete type *NumError
// and include err.Num = s. If s is empty or contains invalid
// digits, err.Err = ErrSyntax and the returned value is 0;
// if the value corresponding to s cannot be represented by a
// signed integer of the given size, err.Err = ErrRange and the
// returned value is the maximum magnitude integer of the
// appropriate bitSize and sign.
func ParseInt(s string, base int, bitSize int) (i int64, err error) {

I need these but fastjson.ParseInt64BestEffort behaves differently.

@yuzhichang yuzhichang changed the title range check when parsing integers compatibility with strconv.ParseInt May 16, 2021
iv-menshenin added a commit to iv-menshenin/fastjson that referenced this issue Feb 20, 2024
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

1 participant