[java] Java Arithmatic Error![solved]

Started by
2 comments, last by Cakey 15 years, 2 months ago
Seriously. I don't know what to say... Java is adding 0's to some of my integer values... Has this ever happened to anyone before? Screen-shot below for the people who don't... believe me... http://i310.photobucket.com/albums/kk420/SmaerdsDreams/Untitled.jpg I've tried rebooting and it's still mucking things up. Any response would be really good right now! [Edited by - Cakey on January 22, 2009 8:23:08 PM]
Advertisement
even weirder!
I commented out my img.flush() line and now it isn't...
You do

System.out.print(w + " / " + xTileWidth" + " = " + tiles);

And then you do (in the for loop):

System.out.println(tile);

The function System.out.print does not add a new line at the end of the print statement (which is what you call in the first line, so the printing cursor is still on the same line). Then you call System.out.println, which does insert a new line after the print statement. System.out.println(tile); is printing 0, but since you're still on the same line, it looks like "20", rather than a "2" followed by a "0". Try changing the first statement to println, or adding some text at the end of the statement.

This would be a great time for you to use the debugger. If you were to step through your program, one line at a time, you would be able to see it print "2" in the first line, and then later on it would print "0", but it would still be on the same line. This would help you quickly diagnose the problem.
[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]
Haha, thanks I'm a bit inebriated. Problem solved however! I feel pretty stupid, I hope I remember what I even coded tonight.

This topic is closed to new replies.

Advertisement