I've been working on an encryption system for a program, and as a means of getting size of the encrypted String down, I decided to allow the system to put numbers into any base - 62 being the max (values going 0-9,A-Z,a-z). I wrote this out fairly quickly, and it works for the most part, but *almost* every output value is off on the last character (even worse if not using base 62).Some example cases:

- 30400066288418849 becomes 2FEQDJkH9F instead of 2FEQDJkH9E (a difference of 1)
- 21392905688514741 becomes 1Zyk6HmZO9 instead of 1Zyk6HmZO8 (a difference of 1)
- 22236810928128038 becomes 1dqNWdRcwg instead of 1dqNWdRcwi (a difference of -2)
- 1407619700686911 becomes 6Rhvv3b0J, which oddly is right?
[...]

I'm sure it's just a small error somewhere, or a tiny oversight, but I've been looking at it on and off for 5 days and still can't see it. System.out.println()-ing each step hasn't been too informative either, as the math seems about right. The digit conversions are all correct too (6=6, 35=Z, 44=i, 61=z, etc).I've been using this site and this one as a means to test my results. Both have the same results, so I think I'm the wrong one here.Any help is greatly appreciated! Cheers!

I've checked all four of them with Matlab and all input numbers convert to what you say your code produce and not what you expect. You can easily see that your expectation for the first two are incorrect: 9 and 1 from the inputs are odd, but E and 8 from your expectations are even, and thus your expectations cannot be correct. However, F and 9 from the values your code produce are indeed odd values.

I tried the converter code in your last link and 30400066288418848, 30400066288418849 and 30400066288418850 all convert to 2FEQDJkH9E, while 30400066288418851 converts to 2FEQDJkH9I. Without looking at that code, I suspect that they are doing the calculations with 64-bit floating point values. Since they only have 53 bits of precision and 30400066288418849 in on the order of 54 bits, there simply isn't enough precision to do precise integer calculations at those magnitudes.

In short, your code produces the correct values (not saying there aren't other corner cases where it may be wrong, just that you examples are correct), and your links are not precise enough for your values.