2 ms·
but couldn't you have a stream algorithm with modular arithmetic? [edit: i thought i had a good demonstration of this. actually, two. but both were wrong. s
by andrewcooke 15y ago
but couldn't you have a stream algorithm with modular arithmetic?
[edit: i thought i had a good demonstration of this. actually, two. but both were wrong. so it does seem to be non-trivial...]
[edit 2: open stack overflow question: http://stackoverflow.com/questions/3545931/efficient-algorithm-for-conversion-between-numeral-system http://stackoverflow.com/questions/3545931/efficient-algorit... ]
- DenisM 15y agoIf we could, we wouldn't call it base62, as base62 normally means converting the entire "bigint" (all bytes of input data as one big number) into base-62 representation. At least that's how baseXX has been used to far (I searched the web before doing this), and I am in favor of sticking to that naming convention. Agreed? Now, whether we could come up with such streaming algorithm I'm not sure. I tried solving this problem, and this is what I came up with. Maybe I haven't tried hard enough to go the other route... I guess you could simply slice the incoming stream into a set of chunks, each small enough to make bigin base62 conversion fast (which is square of the size of the chunk), and yet large enough to obscure the occasional loss of space at the chunk boundaries... I guess that would be an option...
- deleted 15y ago[deleted]
- deleted 15y ago[deleted]