fastjson icon indicating copy to clipboard operation
fastjson copied to clipboard

compatibility with strconv.ParseInt

Open yuzhichang opened this issue 3 years ago • 0 comments

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 avatar May 16 '21 12:05 yuzhichang