1

I have an issue with string conversion:

When using parseInt(string[,radix]) like so:

BigInt(parseInt('something', 36))

it outputs: 80920602611116n. with a different input like so:

BigInt(parseInt('somethink', 36))

it outputs: 80920602611120n, which is something else of course.

However if it's a longer string, the output number is the same sometimes:

BigInt(parseInt('thisisactuallyadifferentsomething', 36))
BigInt(parseInt('thisisactuallyadifferentsomethink', 36))

this would output 1867697451648055638757226289961051507749359223570432n for both, although they are different.

I know, that there is a limit for safe representation of integers, that's why I used BigInt, which has no limit.

I have to be able to differ strings of this size, while using BigInt to represent those.

2
  • 2
    parseInt is losing precision before BigInt Commented Apr 20, 2020 at 15:51
  • For some reason the Javascript BigInt type is relatively crippled compared to every other bigint type in the world. Commented Apr 20, 2020 at 16:09

1 Answer 1

2

See encode a big integer to base62, but replace the following base 62 digits...

var digits = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';

...with the base 36 digits...

var digits = '0123456789abcdefghijklmnopqrstuvwxyz';

Hope this helps...

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.