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

Inconsistent precision for ascending vs descending direction #25

Open
danielberndt opened this issue Dec 18, 2023 · 0 comments
Open

Inconsistent precision for ascending vs descending direction #25

danielberndt opened this issue Dec 18, 2023 · 0 comments

Comments

@danielberndt
Copy link

danielberndt commented Dec 18, 2023

Hi there,

first off, I'm really really amazed by the effort put into this library, especially the README!

I've stumbled across one inconsistency though:

base62.mudder("0", "z", 1, undefined, 1000000)[0] // -> "000E"
base62.mudder("z", "0", 1, undefined, 1000000)[0] // -> "y"

i.e. when going from 0 to z the precision automatically adapts to the expected numDivisions, whereas it doesn't do so when going from z to 0. I've seen the discussion #7 and the addition of the placesToKeep parameter.
I'm wondering though whether it was possible for the library itself to determine the appropriate precision when using a descending order.

In the meantime I probably will add something along the lines of placesToKeep: Math.round(Math.log(numDivisions) / Math.log(maxBase)) to my code for this special case as it feels like it results in the desired precision. (yzzl for the case above)

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

1 participant