this was supposed to be a simple stripped down BASE64 decoder done in java.
i don't (can't) use a lot of standard libraries because this App will be run on PDAs and java enabled cellphones, so SIZE does matter.
no problem, i get one of my contractors the BASE64 specs and some sample implementations ...
he's been fighting with this for 3 days now so i get his sourcefile and have a look at it this morning.
looks OK at first glance, but when you run it, it sporadically spits out wrong bytevalues while some decode just fine.
wtf?
so i spend all day going through his code (which is not that much) and i just can't figure out what's wrong.
then finally, about 15 minutes ago it dawns on me, have a look at this:
bReturn2[nn+2] = (byte)(iRes % 0xFF);
bReturn2[nn+1] = (byte)((iRes >> 8) % 0xFF);
bReturn2[nn+0] = (byte)((iRes >> 16) % 0xFF);
bReturn2 is a byte array, iRes a integer, the purpose is to roll the lower 3 bytes of the integer into 3 sequential fields in the byte array.
i had been staring at this for 6 hours and couldn't figure out what was wrong.
all the while it was right in front of me, plain sight, right there ...
can you find the error?
Andy
PS: did i mention that i HATE going through someone else code?