Logic Errors

So we all get them from time to time. But how long have you previously spent trying to spot such a simple cause of an error?
Pretty recently I was setting up the boundaries of the camera in a game. This was my algorithm.

if(camera.position.x + Gdx.app.getGraphics().getWidth() => map.getWidth()) {
    moveX = map.getWidth() - camera.position.x + Gdx.app.getGraphics().getWidth();
}

I spent 5 hours debugging it, wondering why it moved the camera 2048px. This error has to be such a classic.
But yeah, you have to love the rush from fixing them. :smiley:

About six hours spent fixing a stupid obvious error…

My largest error happened when I was learning JNI. I’ve spent three days scratching my head about the linking error unresolved symbol. Then my brother pointed out, I’ve forgotten to link with the JVM.

An entire 8 hour shift only to find that I called a method of the same name from the wrong class…

Spent about two days figuring out why my view matrix was buggy. Turned out I rotated my rotation matrix with degrees instead of radians. :stuck_out_tongue:

Spent a while trying to figure out why my vertex shader wasn’t compiling only to realize I had put a colon instead of a semi-colon after a line of code :frowning:

Spent one week with no coding whilst looking for a bug. Turned out I was using “1” in for loop rather than “i”. I recon this was my IDE auto-completing to the wrong thing, but I still should have noticed.

Biggest reason why I complain about the bracket-less/single line control statement (in Java):

I was working on a project for my BS in CS editing another team member’s code to provide a better reader for an XML document we had to parse. I always use brackets, he didn’t. So I was reading his code like it was mine. I added a line to an if statement and could not, for the life of me, figure out why that line was always executing. It took me about eight hours to discover that error.

I believe that when i first started coding in java, I spent about a week trying to get a timer to work. Turns out that I imported the wrong Timer class

Ah yes, I remember last year in my coding class my teacher had to keep telling the other students to import the javax timer, not the other one.

No, I absolutely HATE it, because it’s always something like a hidden typo that is impossible to find.

Not so much a logic error, but once I spent 10 minutes debugging a shader to find that I missed a semicolon. >:(
Then I spent another few minutes trying to find another bug, which turned out to be a missing letter in a variable name. >:(

I have spent so much of my programming time debugging shaders. :cranky:

I’ve been unable to get shaders working for several weeks, but today I realized that in my shader loader, I was appending ‘/n’ to each line instead of ‘\n’ ._.