Re: Another red alert problem -_- [message #418175 is a reply to message #418135] |
Fri, 22 January 2010 06:38 |
|
Omar007
Messages: 1711 Registered: December 2007 Location: Amsterdam
Karma:
|
General (1 Star) |
|
|
Toggle Spoilerdanpaul88 wrote on Thu, 21 January 2010 12:02 |
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
|
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....)
|
Well in the time i programmed i never had anything like that xD
And i didnt stated windows shouldnt have a handling for that error, i only didnt thought it had
@GOL14TH; So when starting a mission it doesnt crash anymore?? 0o
(you have plain RA or TFD??)
[Updated on: Fri, 22 January 2010 06:40] Report message to a moderator
|
|
|