Mail Archives: djgpp/1998/08/24/16:01:53
In <6rqttc$dfl AT news1 DOT snet DOT net>, "Mark Figura" <nospam AT please DOT com> writes:
>var = (color1-color2)/(x1-x2);
>If I don't test to make sure that x1 != x2 before I use this equation, my
>memory gets all weird or something. (My triangle gets all big and weird
>looking). I should get a FPE, shouldn't I, if there's a divide by 0?
No, not if you're using floating-point variables - then you'll get Infinity or "Inf",
and no exception at all.
It's possible to express the Infinity state with floating point variables.
However, if you're use integers, you are right - you should get an divide-by-zero
exception.
Just try this:
-----------
double a=5, b=0;
double c = a / b;
printf("%f\n", c);
-----------
It doesn't cause an exception when I run it.
--
---- Morten Stenshorne, Gommerud, 3320 Vestfossen, NORWAY ----
-- mstensho AT powertech DOT no -- http://home.powertech.no/mstensho/ --
---- Computer Engineer -- Phone: 93440112 -- Doofuz AT IRCNet ----
- Raw text -