Inconsistent precision for ascending vs descending direction
danielberndt opened this issue · 0 comments
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)