-
Notifications
You must be signed in to change notification settings - Fork 600
Open
Labels
Description
I also encountered this error:
https://stackoverflow.com/a/52524228
I was about to implement this TS function:
function getToken(id: string) {
return ((Number(id) / 1e15) * Math.PI).toString(36).replace(/(0+|\.)/g, '')
}in golang and wanted to use JS interpreter as validation. But it does not work as expected.
When I run it for the a twitter ID, it does just generate the first "part" of the result.
Everything after and including the dot, is missing (the dot gets removed anyway), but the token after the dot is missing as well.
Expected result:
4dh7jvecqt6
actual result:
4dh
Here what this function does:
- take a string
- convert to float64 (maybe float36? - not too sure about this one)
floatNum := (num / 1e15) * math.Pi- convert float to
base36 - remove all zeros and dots (
0&.)
That is all. But this tool, does not do this properly, it converts the string to an int and converts the int to base36. Which is missing some operations.