Jump to content
  • Advertisement
Sign in to follow this  
JD_Rushing

Dividing by zero, on purpose

This topic is 2181 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

Just curious if anyone else does this.

Sometimes I have an if statement block I don't know is running.  I know the code before, and after, the block is running fine.

So, I put a divide by zero after it.  I know there are more sophisticated ways of debugging, and I have used them.  But for a quick and dirty, I make an error by dividing by zero.  I was going to stop the program anyways.

 

So I was just curious if anyone has ever purposely made an error in a section of code to see if part of it was running or not?

 

Share this post


Link to post
Share on other sites
Advertisement

I'm with Khaiy. Depending on the language, I either go with breakpoints, alerts/message boxes, or debug printing (usually to the console, but, for instance, PHP and webpages, I just print to the page).

Share this post


Link to post
Share on other sites

The only time I've ever deliberately put a divide by zero into my code was to check if my exception handler was actually catching divide by zero and other non-C++ exceptions. 

Share this post


Link to post
Share on other sites

If I'm about to head home for the day and I'm working on a piece of code that is incomplete but compilable, I'll type some garbage like: "dgsahjgda". That way when I come back to it in the morning If I forget where I was up to, it'll take me straight to the garbage when I try to compile. 

 

I'll do the same if I'm doing some manual refactoring involving a lot of copy and pasting.

I do this too, but instead of garbage, I write down the possible reason for why the code might be failing, or whatever thought I happened to have about it.

Share this post


Link to post
Share on other sites

 

If I'm about to head home for the day and I'm working on a piece of code that is incomplete but compilable, I'll type some garbage like: "dgsahjgda". That way when I come back to it in the morning If I forget where I was up to, it'll take me straight to the garbage when I try to compile. 

 

I'll do the same if I'm doing some manual refactoring involving a lot of copy and pasting.

I do this too, but instead of garbage, I write down the possible reason for why the code might be failing, or whatever thought I happened to have about it.

 

 

#error

 

is probably what you are looking for.

 

Breakpoints is what the OP is looking for?

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!