Home  |  Forums  |  914 Info  |  Blogs
 
914World.com - The fastest growing online 914 community!
 
Porsche, and the Porsche crest are registered trademarks of Dr. Ing. h.c. F. Porsche AG. This site is not affiliated with Porsche in any way.
Its only purpose is to provide an online forum for car enthusiasts. All other trademarks are property of their respective owners.
 

Welcome Guest ( Log In | Register )

> WOT: ARRGGHHH, i hate fixing someone elses code!, F%^$SH*&@@@
SirAndy
post Aug 15 2005, 07:33 PM
Post #1


Resident German
*************************

Group: Admin
Posts: 41,654
Joined: 21-January 03
From: Oakland, Kalifornia
Member No.: 179
Region Association: Northern California



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 ... (IMG:http://www.914world.com/bbs2/html/emoticons/headbang.gif)

can you find the error?
(IMG:http://www.914world.com/bbs2/html/emoticons/idea.gif) Andy

PS: did i mention that i HATE going through someone else code?
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Posts in this topic
SirAndy   WOT: ARRGGHHH, i hate fixing someone elses code!   Aug 15 2005, 07:33 PM
SpecialK   I have NFI, but I'd guess you're missing a...   Aug 15 2005, 08:02 PM
Midtowner   Sounds all Japanese to me! htt...   Aug 15 2005, 08:15 PM
!   Or ya got extra ones....parenthesis that is....   Aug 15 2005, 08:27 PM
Foxman   bReturn2[nn+2] = (byte)(iRes % 0xFF); What are yo...   Aug 15 2005, 08:29 PM
johnmhudson111   ...   Aug 15 2005, 08:29 PM
SirAndy     Aug 15 2005, 08:35 PM
johnmhudson111   <...   Aug 15 2005, 08:36 PM
jonwatts   I would have used the '&' operator instead...   Aug 15 2005, 08:37 PM
r_towle   <...   Aug 15 2005, 08:58 PM
SirAndy   ...   Aug 15 2005, 09:07 PM
jonwatts   Dumb question. Is your input base10 or base16? It ...   Aug 15 2005, 09:07 PM
ematulac   edit: nevermind ... modulus looked strange to me t...   Aug 15 2005, 09:08 PM
jonwatts   WOW, and I am such a suck-ass programmer too, but ...   Aug 15 2005, 09:09 PM
SirAndy   ...   Aug 15 2005, 09:10 PM
Foxman   damn, I never thought about the input.   Aug 15 2005, 09:12 PM


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 24th May 2024 - 11:29 AM