Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > comp.lang.java.programmer > #6568

Re: Arithmetic overflow checking

From Thomas Richter <thor@math.tu-berlin.de>
Newsgroups comp.lang.java.programmer
Subject Re: Arithmetic overflow checking
Date 2011-07-26 09:43 +0200
Organization InterNetNews at News.BelWue.DE (Stuttgart, Germany)
Message-ID <j0lr6i$p6$1@news.belwue.de> (permalink)
References (16 earlier) <slrnj2mdoi.6gl.avl@gamma.logic.tuwien.ac.at> <j0g1i4$nus$1@speranza.aioe.org> <ueidnUcxuMPT2LHTnZ2dnUVZ_uKdnZ2d@earthlink.com> <j0j5ie$v55$1@speranza.aioe.org> <6bmdnfQwfsYovLDTnZ2dnUVZ_qydnZ2d@earthlink.com>

Show all headers | View raw


Am 25.07.2011 09:56, schrieb Patricia Shanahan:
> 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<T
>>>> extends Number<T>> 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.

Not at all! There was simply no need to solve quadratic equations like 
x^2 + 4 = 0 simply because everyone knew, and it was obvious, that this 
equation *does not have* a solution.

Complex numbers were invented as a tool to solve *cubic* equations. The 
tricky thing is that, if you want to solve a cubic equation, you *know* 
that it must either have one, two or three solutions, ever. However, in 
the three-solution case, a closed formula for computing the solutions 
was found, but this equation required you, somewhere in the middle, to 
handle with roots of negative numbers. All these strange negative roots 
then vanish again in the final solution using rules like sqrt(-1) * 
sqrt(-1) = -1, and then cancel out, so everything was "correct" in the 
end. All what happened then is that these rules for manipulating the 
strange temporary = "imaginary" numbers where written down, and *this* 
gave the complex numbers.

Thus, complex numbers weren't an abstract invention by crazy 
mathematicians trying to solve what wasn't possible to solve, but rather 
as a toolkit to solve something very practical, namely to apply an 
algorithm for solving cubic(!) equations. This is very much a useful 
task, as it is to use complex numbers to describe AC currents.

That java lacks operator overloading is a historic decision, probably 
taken on the basis that C++ started with this feature, and everyone 
considered it "so cool" that it was misused for all types of nonsense. 
Basically, I don't consider the choice of the C++ STL to use << and >> 
operators for input and output a sane one, and probably the java 
language designers had the same impression, so wanted to avoid it, but 
then overdid it by disallowing operator overloading in total.

Nowadays, one can probably say that operator overloading *is* a useful 
tool, but as for all useful tools it is one that should be handled with 
care, and a tool that can cause quite some trouble in the hands of 
fools. Thus, what C++ overdid, and Java "under"-did. From today's 
perspective, I *would* prefer to have operator overloading in java, but 
apply it only where it makes sense and the semantics of operators is 
correct. That is, apply it to numeric types (numbers including complex 
numbers, matrices, vectors). Appyling it to I/O as does C++ is, IMHO, 
not a good idea.

Greetings,
	Thomas

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Re: Arithmetic overflow checking Arne Vajhøj <arne@vajhoej.dk> - 2011-07-19 20:54 -0400
  Re: Arithmetic overflow checking markspace <-@.> - 2011-07-19 18:07 -0700
    Re: Arithmetic overflow checking Arne Vajhøj <arne@vajhoej.dk> - 2011-07-19 21:31 -0400
      Re: Arithmetic overflow checking Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-07-20 07:36 -0300
        Re: Arithmetic overflow checking RedGrittyBrick <RedGrittyBrick@spamweary.invalid> - 2011-07-20 11:58 +0100
          Re: Arithmetic overflow checking lewbloch <lewbloch@gmail.com> - 2011-07-20 09:51 -0700
            Re: Arithmetic overflow checking RedGrittyBrick <RedGrittyBrick@spamweary.invalid> - 2011-07-21 12:11 +0100
              Re: Arithmetic overflow checking Martin Gregorie <martin@address-in-sig.invalid> - 2011-07-21 12:43 +0000
                Re: Arithmetic overflow checking Tom McGlynn <taqmcglynn@googlemail.com> - 2011-07-21 07:15 -0700
              Re: Arithmetic overflow checking lewbloch <lewbloch@gmail.com> - 2011-07-21 07:35 -0700
                Re: Arithmetic overflow checking Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-07-21 15:38 +0000
                Re: Arithmetic overflow checking lewbloch <lewbloch@gmail.com> - 2011-07-21 09:03 -0700
                Re: Arithmetic overflow checking Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-07-21 12:00 -0700
                Re: Arithmetic overflow checking Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-07-22 17:16 +0000
                Re: Arithmetic overflow checking David Lamb <dalamb@cs.queensu.ca> - 2011-07-23 11:28 -0400
                Re: Arithmetic overflow checking Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-07-23 21:03 +0000
                Re: Arithmetic overflow checking Henderson <h1@g1.f1> - 2011-07-23 22:55 -0400
                Re: Arithmetic overflow checking Patricia Shanahan <pats@acm.org> - 2011-07-24 09:16 -0700
                Re: Arithmetic overflow checking markspace <-@.> - 2011-07-24 10:40 -0700
                Re: Arithmetic overflow checking Patricia Shanahan <pats@acm.org> - 2011-07-24 10:54 -0700
                Re: Arithmetic overflow checking markspace <-@.> - 2011-07-24 11:09 -0700
                Re: Arithmetic overflow checking Patricia Shanahan <pats@acm.org> - 2011-07-24 12:53 -0700
                Re: Arithmetic overflow checking markspace <-@.> - 2011-07-24 15:15 -0700
                Re: Arithmetic overflow checking Patricia Shanahan <pats@acm.org> - 2011-07-24 15:41 -0700
                Re: Arithmetic overflow checking Henderson <h1@g1.f1> - 2011-07-25 03:21 -0400
                Re: Arithmetic overflow checking Patricia Shanahan <pats@acm.org> - 2011-07-25 00:56 -0700
                Re: Arithmetic overflow checking Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-07-25 07:03 -0300
                Re: Arithmetic overflow checking Thomas Richter <thor@math.tu-berlin.de> - 2011-07-26 09:43 +0200
                Re: Arithmetic overflow checking Andreas Leitgeb <avl@gamma.logic.tuwien.ac.at> - 2011-07-25 11:06 +0000
                Re: Arithmetic overflow checking Henderson <h1@g1.f1> - 2011-07-25 11:12 -0400
                Re: Arithmetic overflow checking Patricia Shanahan <pats@acm.org> - 2011-07-25 09:09 -0700
                Re: Arithmetic overflow checking Patricia Shanahan <pats@acm.org> - 2011-07-25 09:30 -0700
                Re: Arithmetic overflow checking David Lamb <dalamb@cs.queensu.ca> - 2011-07-25 13:33 -0400
                Re: Arithmetic overflow checking "John B. Matthews" <nospam@nospam.invalid> - 2011-07-26 03:04 -0400
                Re: Arithmetic overflow checking Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-07-26 03:28 -0400
                Re: Arithmetic overflow checking Henderson <h1@g1.f1> - 2011-07-26 04:53 -0400
                Re: Arithmetic overflow checking Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-07-26 11:35 -0400
                Re: Arithmetic overflow checking Patricia Shanahan <pats@acm.org> - 2011-07-26 10:48 -0700
                Re: Arithmetic overflow checking Arne Vajhøj <arne@vajhoej.dk> - 2011-07-21 17:00 -0400
        Re: Arithmetic overflow checking Arne Vajhøj <arne@vajhoej.dk> - 2011-07-20 19:50 -0400
          Re: Arithmetic overflow checking Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-07-20 23:21 -0300
            Re: Arithmetic overflow checking Martin Gregorie <martin@address-in-sig.invalid> - 2011-07-21 12:52 +0000
              Re: Arithmetic overflow checking Henderson <h1@g1.f1> - 2011-07-21 15:58 -0400
            Re: Arithmetic overflow checking Arne Vajhøj <arne@vajhoej.dk> - 2011-07-21 17:06 -0400
      Re: Arithmetic overflow checking Gene Wirchenko <genew@ocis.net> - 2011-07-20 14:35 -0700
        Re: Arithmetic overflow checking Arne Vajhøj <arne@vajhoej.dk> - 2011-07-20 18:22 -0400
          Re: Arithmetic overflow checking Gene Wirchenko <genew@ocis.net> - 2011-07-21 14:54 -0700

csiph-web