Re: [pure-lang-users] complex 0
Status: Beta
Brought to you by:
agraef
From: Albert G. <Dr....@t-...> - 2008-09-11 10:31:52
|
Albert Graef wrote: > Good point! In fact gcc seems to do that, too (I get nan+:nan for /0.0 > just as well as for /(0.0+I*0.0). As a matter of fact, Haskell gives the same results, too (at least Hugs does), and the Haskell report uses the same formulas as math.pure in the complex/complex case. I'm beginning to wonder whether it's really worth the hassle to follow the ISOC99 recommendations concerning the treatment of infinities and NaNs for complex * and /. The algorithms in Annex G do look like a kind of kludge to me, and they employ C99 functions for extracting and scaling the exponents of floating point numbers which might not be available on some systems (such as Windows), at least not directly. Hence special support in the runtime would be needed to implement these in a portable way across all platforms. That seems like an awful lot of kludges to just make those nan+:nan's go away, considering that Pure also offers the polar representation where you'll get the correct infinite results for division by zero and similar cases, as long as the phase angles are finite. So actually John's suggestion seems to be the most reasonable: just promote real operands of * and / to complex, then the results will at least be consistent. Or does anyone here really need the ISOC recommended behaviour? Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |