Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Technical Support » Other » Another red alert problem -_-
Re: Another red alert problem -_- [message #418135 is a reply to message #418126] Thu, 21 January 2010 04:02 Go to previous messageGo to previous message
danpaul88 is currently offline  danpaul88
Messages: 5795
Registered: June 2004
Location: England
Karma:
General (5 Stars)
Omar007 wrote on Thu, 21 January 2010 10:27

I didnt even know windows would have an error for such thing because its kinda obvious you shouldnt divide by 0 in programs Razz


Why *wouldn't* Windows have an error for it then? Clearly it's impossible to divide by 0, but you would be surprised how easily it can happen in a program...

Take for instance the following code;

int b = 5;
int c = myFunction();
int a = b / c;


Seems innocent enough, but what happens if myFunction returns 0 for some reason? Simple - you get a divide by 0 error. Now consider that there could be tens or even hundreds of other lines of code between those lines and that they might not even be in the same file as each other and you see just how easy it can be for a program to accidentally cause a divide by 0 exception.

Good programming technique would of course have you check whether the divisor is 0 before performing the calculation but that's sometimes unnecessary overhead and perhaps when the code was written it was dividing by a variable which should never be set to 0 and, at a later stage of development, it was decided that 0 would in fact be a valid value for the variable, perhaps to indicate a new state that was introduced to the program. That old function that assumed it would never be set to 0 is now a ticking timebomb waiting to go off.

So stating that Windows should not catch divide by 0 errors simply because you shouldn't try and do it in the first place is utterly absurd.



/RANDOM RANT


(I am doing coursework and it's stressful ^^ Apologies for taking it out on the forums by typing long, rambling and ultimately pointless rants....)


http://steamsignature.com/card/1/76561197975867233.png

[Updated on: Thu, 21 January 2010 04:02]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Picture turns black when i take SS on red alert
Next Topic: Secondary Monitor and Vid Card Question
Goto Forum:
  


Current Time: Sun Nov 24 01:30:52 MST 2024

Total time taken to generate the page: 0.00916 seconds