Jump to content
  • Advertisement
Sign in to follow this  
Cakey

[java] Java Arithmatic Error![solved]

This topic is 3412 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Haha, thanks I'm a bit inebriated. Problem solved however! I feel pretty stupid, I hope I remember what I even coded tonight.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!