PDA

View Full Version : help with divide by zero error!!!



10-19-2001, 02:58 AM
i am making a cheap car game in VB (don't pay me out) and it works on my PC with win98 but when i send the compiled version to my friends with win98 they get the "divide by zero" error. it works fine in XP aswell.

can anyone help with that?

witcomb
10-19-2001, 04:39 AM
My recommendation is watch your divisions, if there is a case for divide by zero then handle it, don't just assume things will be well.

ie.
aspect = height / width;
use this instead
aspect = (width != 0.0) ? (height / width) : 0.0;

Hope this helps, sorry I don't know VB so no VB code http://www.opengl.org/discussion_boards/ubb/smile.gif
Neil

02-19-2003, 12:40 AM
I am getting the same problem. My program works on all other computers except for a new one that I recently purchased.



Originally posted by Darkside:
i am making a cheap car game in VB (don't pay me out) and it works on my PC with win98 but when i send the compiled version to my friends with win98 they get the "divide by zero" error. it works fine in XP aswell.

can anyone help with that?

Gavin
02-19-2003, 07:06 AM
Just a guess here but different os's handling floating point (near to zero) differently.... your machine may be happy with 0.1 * 10^-30 but others may flag this as divide by zero.

gking
02-19-2003, 09:59 AM
Division by a floating-point zero won't cause an exception -- it will result in either +-INF or qNaN.

Make sure that your friend has the same version of the runtime DLLs that you have. Is there some difference between your Windows 98 versions (SE, SP3, etc.)? Try to eliminate any variables.

Also, with Visual C++, if you compile a program in Debug mode, all memory is initially striped (0xcdcdcdcd), but if you compile in release mode, all memory is initially zeroed (0x00000000). Visual BASIC may have similar behavior, so make sure that you initialize all variables before you use them (especially if you are running in Debug mode, and you sent your friend a Release executable).