From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10c696,c887bec98cd793ef X-Google-Attributes: gid10c696,public X-Google-Thread: 111c93,c887bec98cd793ef X-Google-Attributes: gid111c93,public From: "Anthony W. Youngman" Subject: Re: division by zero exceptions ? Date: 1998/11/01 Message-ID: #1/1 X-Deja-AN: 407356642 X-NNTP-Posting-Host: thewolery.demon.co.uk:158.152.222.21 References: <01be0482$6ebd1e60$45934b0c@default> <71f8bc$clh$3@newnews.nl.uu.net> X-Complaints-To: abuse@demon.net X-Trace: news.demon.co.uk 909959010 nnrp-10:24978 NO-IDENT thewolery.demon.co.uk:158.152.222.21 Organization: vinny-puch MIME-Version: 1.0 Reply-To: "Anthony W. Youngman" Newsgroups: comp.os.linux.alpha,comp.os.linux.development.apps In article , Bill Metzenthen writes >On Sat, 31 Oct 1998 21:23:20 +0000, Anthony W. Youngman > wrote: > >>See my other post - if I'm doing math, I WANT it to return the correct >>value, ie if I say "x = y / tan( pi / 2)" then I WANT x to be set to >>infinity. If I don't have to trap for divide by zero, then my thousand >>lines becomes five hundred, and it's a damn sight easier to debug. >> >>Look at it as a mathematician, not an engineer. x divided by 0 IS >>infinity, and I wish computers could cope with that fact, and not crash >>my program. > >Hang on a moment, what do you mean by infinity? In the type of >mathematics which most people would like to approximate with >floating point mathematics, there is no such thing as infinity: >x/0 is not a legal operation! > >I was interested to see your example where this fictitious object can >be useful. Part of my background is in electrical engineering where >having infinity can be useful e.g. when computing the impedance of >parallel circuit branches when one of the branches is a short circuit. >I thought that this was one of the few cases where the 1/0 = infinity >behaviour was useful; your example adds one more to my list (1). > >For most computations 1/0 represents a severe error which should be >dealt with as soon as it occurs. I've actually remembered exactly what I was doing. I wanted to plot wave height at a particular point in the ocean (iteratively - I was building an extremes map) and I had a tape of tropical storm data. So for each storm in turn, I took the first segment (start-pos, end-pos) and calculated the distance from my point to the storm track, then took the next segment, calculated the distance and kept the shortest distance, etc etc. I then had a list of "maximum wave height from each storm". As you can see, it's quite an interesting problem. I think all my coordinates were integer minutes, but I had to calculate the formula of the line of the storm track, then calculate the formula of a line perpendicular to the track through my point. From that I could work out if the perpendicular intercepted the track in which case that gave me my distance, else work out which end of the track was closest to the perpendicular and use that to give me my distance. As you can see, if either d(lat)=0 or d(long)=0 my code would screw up. You state that >For most computations 1/0 represents a severe error but I would beg to differ. For trig and algebra, 1/0 is a linear infinity, and (like with eg superstrings) you don't give a damn about infinity provided at the end they all cancel out and give you your answer. Which for trig and algebra you know they will. I agree that when you start dividing different degrees of infinity by each other things start getting complicated ... It's just a case of knowing your infinities (yes there are an INFINITE NUMBER of them, I believe :-) -- Anthony W. Youngman - wol at thewolery dot demon dot co dot uk Trousers with a single hole in their waistband are topologically equivalent to a doughnut. These sugarcoated trousers have yet to catch on at fast-food outlets! (SuperStrings by F. David Peat) If replying by e-mail please mail wol. Anything else may get missed amongst the spam.