home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / cplus / 17842 < prev    next >
Encoding:
Internet Message Format  |  1992-12-11  |  1.9 KB

  1. Xref: sparky comp.lang.c++:17842 comp.lang.c:18234 comp.programming:3311
  2. Path: sparky!uunet!cs.utexas.edu!sun-barr!decwrl!deccrl!news.crl.dec.com!dbased.nuo.dec.com!nntpd.lkg.dec.com!sousa.tay.dec.com!talent.ljo.dec.com!gibian
  3. From: gibian@talent.ljo.dec.com (Marc S. Gibian)
  4. Newsgroups: comp.lang.c++,comp.lang.c,comp.programming
  5. Subject: Re: How to make 3/0=INFINITY?
  6. Keywords: INFINITY, ADT
  7. Message-ID: <2314@sousa.tay.dec.com>
  8. Date: 11 Dec 92 22:41:44 GMT
  9. References: <ByC0Jx.1nF@math.uwaterloo.ca> <1992Nov27.072223.24022@donau.et.tudelft.nl> <1992Dec3.154907.25856@cis.ohio-state.edu>
  10. Sender: newsa@sousa.tay.dec.com
  11. Reply-To: gibian@ljohub.enet.dec.com
  12. Followup-To: comp.lang.c++
  13. Organization: Digital Equipment Corporation
  14. Lines: 29
  15.  
  16.  
  17. Many moons ago, when I was a math wiz, I did indeed spend a section of
  18. a mathematics class on theory of infinity.  At the time it was fun, looking
  19. back it reminds me a lot of the current work in area of chaos theory.
  20.  
  21. But, this is comp.programming, so why not answer the initial question:
  22.  
  23. "How can I program so that 3 divided by 0 results in infinity?"
  24.  
  25. The hardware types have pointed to the IEEE standard for floating point
  26. computations.  Thats nice, but once again this is comp.programming, so
  27. here's a software solution:
  28.  
  29. Use a language supporting operator overloading and data hidding, c++ and
  30. ADA come to mind first, and define your own data type ... how about
  31. infinite.  The data structure would contain:
  32.  
  33.    real_value - a floating point number when values are not infinite
  34.  
  35.    infinite_value - an enumeration of values... based on my math
  36.                     experience, it would be:
  37.                      (negative-infinity, real, positive-infinity)
  38.  
  39. The function definitions are left as an exercise (as I have to beat the
  40. blizzard home ;-)
  41. --
  42. Marc S. Gibian            email: gibian@talent.ljo.dec.com
  43. Principal Software Engineer    phone: (508) 486-6598
  44. Digital Equipment Corporation    fax:   (508) 486-6648  or (508) 486-6100
  45.