www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/08/24/16:01:53

From: mstensho AT powertech DOT no (Morten Stenshorne)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: What the $##@$ is going on here!?!?!?
Date: Mon, 24 Aug 1998 19:26:51 GMT
Organization: Pinkadux sukkerfrie skrusokker
Lines: 24
Sender: mstensho AT vangelis DOT dyn DOT ml DOT org
Message-ID: <c0.9w.2Md6dl$05o@vangelis.dyn.ml.org>
References: <6rqttc$dfl AT news1 DOT snet DOT net>
Reply-To: mstensho AT powertech DOT no (Morten Stenshorne)
NNTP-Posting-Host: s01i21-0052.no.powertech.net
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019