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

doesnt round trip even 10 places #25

Closed
jeacott1 opened this issue Jan 31, 2017 · 1 comment
Closed

doesnt round trip even 10 places #25

jeacott1 opened this issue Jan 31, 2017 · 1 comment

Comments

@jeacott1
Copy link

var Base62=require('base62');
var maxv= Base62.decode("ZZZZZZZZZZ");
var mmaxv = Base62.encode(maxv);
console.log("maxv=" +maxv+" mmaxv="+mmaxv);


>   maxv=839299365868340200 mmaxv=10000000000
@kchapelier
Copy link
Contributor

kchapelier commented May 15, 2017

This is due to the numbers being represented in JavaScript as IEEE 754 double-precision binary floating-point (wiki) thus being only able to precisely represent integers up to 53 bits long (the value of Number.MAX_SAFE_INTEGER, or Math.pow(2, 53) - 1).

The only way to bypass that would be to use custom number representation such as the bignum and big-integer modules. Some other base64 modules (b64) base62 modules (b62) are doing just that, but it comes at a cost.

@andrew andrew closed this as completed Oct 16, 2017
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

3 participants