Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.glorb.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!newsfe14.iad.POSTED!8ad76e89!not-for-mail From: Arved Sandstrom User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.18) Gecko/20110617 Lightning/1.0b2 Thunderbird/3.1.11 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: Arithmetic overflow checking References: <015aeb15-57db-48ab-9cd4-77f8448b632f@w24g2000yqw.googlegroups.com> <09fe171s46ilvq9qmn254dctunm6noh0ps@4ax.com> <4e262731$0$314$14726298@news.sunsite.dk> <4e26300b$0$309$14726298@news.sunsite.dk> <4e26b4ed$0$2501$db0fefd9@news.zen.co.uk> <4e28097f$0$2533$da0feed9@news.zen.co.uk> <7a23c9d2-508f-4dbd-af91-8cdf2a9764e1@p29g2000pre.googlegroups.com> <6bmdnfQwfsYovLDTnZ2dnUVZ_qydnZ2d@earthlink.com> In-Reply-To: <6bmdnfQwfsYovLDTnZ2dnUVZ_qydnZ2d@earthlink.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Lines: 54 Message-ID: X-Complaints-To: abuse@newsgroups-download.com NNTP-Posting-Date: Mon, 25 Jul 2011 10:03:50 UTC Organization: Public Usenet Newsgroup Access Date: Mon, 25 Jul 2011 07:03:48 -0300 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6529 On 11-07-25 04:56 AM, Patricia Shanahan wrote: > On 7/25/2011 12:21 AM, Henderson wrote: >> On 24/07/2011 12:16 PM, Patricia Shanahan wrote: >>> On 7/23/2011 7:55 PM, Henderson wrote: >>>> We could go further and rewrite Number.java so that it is Number>>> extends Number> and defines: >>> >>> I don't think it would be wise to tie operator overloading to Number. >>> Number defines a series of conversions that make some sense for those >>> types that represent subsets of the real line. >> >> I wasn't thinking beyond the real line to the more abstract stuff >> mathematicians futz around with and consider to have addition and >> multiplication. > > Historically, complex numbers were indeed invented by and for > mathematicians for the abstract satisfaction of having solutions for all > quadratic equations. However, as happens surprisingly often when > mathematicians think they have invented something abstract for their own > amusement, scientists and engineers turned them into useful tools for > practical uses. > > For example, a complex number can represent both magnitude and phase of > an alternating current. That simplifies some electrical engineering > calculations. > > I've seen far too many uses of complex numbers in scientific and > engineering programs to be really comfortable with the fact that Java > lacks a practical way to express anything other than the simplest > complex number expressions. > > Patricia I agree. Unless it were a trivial and very limited use of complex numbers I'd likely skip Java as a candidate for doing that work. But if the application had a moderate need for complex numbers, but also a compelling argument for using Java for most of the logic, I would consider Scala for the complex numbers bit. Or Jython for that matter. But for an application that was all about science and engineering computations my first few choices of programming languages would not include Java anyway. Nor C#, even though that has much better support for complex. Just as when I was doing primarily scientific programming (12 or more years ago) I believe that faced with the same questions today I'd still look first at what language has got the best built-ins and libraries for the specific job, including not just data manipulation but also data visualization. Another interesting consideration is languages that have type systems that support the notion of dimension. I've played a bit with that in F# and Fortress, and I believe that language support for units of measure is also very important in ensuring program correctness. AHS