sidorares / json-bigint

JSON.parse/stringify with bigints support
MIT License
790 stars 189 forks source link

Error parsing string with `useNativeBigInt` mode #88

Open hdoan741 opened 11 months ago

hdoan741 commented 11 months ago

It seems the parser is incorrect when parsing fractional number:

> jsbi({useNativeBigInt: true}).parse('-0.3333333333333333')
Uncaught SyntaxError: Cannot convert -0.3333333333333333 to a BigInt
victorkirov commented 4 months ago

I don't think this is an error. You can't parse a decimal into a bigint in JS. You should probably only be using useNativeBigInt: true if you're 100% sure that your payload won't have decimals in it.