Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


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

Re: Arithmetic overflow checking

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail
NNTP-Posting-Date Sun, 24 Jul 2011 11:16:13 -0500
Date Sun, 24 Jul 2011 09:16:08 -0700
From Patricia Shanahan <pats@acm.org>
User-Agent Mozilla/5.0 (Windows NT 5.2; WOW64; rv:5.0) Gecko/20110624 Thunderbird/5.0
MIME-Version 1.0
Newsgroups comp.lang.java.programmer
Subject Re: Arithmetic overflow checking
References <015aeb15-57db-48ab-9cd4-77f8448b632f@w24g2000yqw.googlegroups.com> <koic171t5gas91890r8l9914v26snm7k1v@4ax.com> <b3d4a08b-3428-442a-8cce-30edc2868a47@5g2000yqb.googlegroups.com> <09fe171s46ilvq9qmn254dctunm6noh0ps@4ax.com> <f6ed8d08-bc7a-43e4-aecf-878511705353@j15g2000yqf.googlegroups.com> <4e262731$0$314$14726298@news.sunsite.dk> <j059o8$684$1@dont-email.me> <4e26300b$0$309$14726298@news.sunsite.dk> <cdyVp.5929$Vn5.2217@newsfe18.iad> <4e26b4ed$0$2501$db0fefd9@news.zen.co.uk> <f126e0ad-e1e5-47c8-949e-e38b3598d5ff@m5g2000prh.googlegroups.com> <4e28097f$0$2533$da0feed9@news.zen.co.uk> <f9939820-502d-4973-b008-0b62536ab967@m3g2000pre.googlegroups.com> <slrnj2ghv0.6gl.avl@gamma.logic.tuwien.ac.at> <7a23c9d2-508f-4dbd-af91-8cdf2a9764e1@p29g2000pre.googlegroups.com> <j09t06$4bo$1@dont-email.me> <slrnj2jc3u.6gl.avl@gamma.logic.tuwien.ac.at> <IMBWp.68441$5v5.52239@newsfe11.iad> <slrnj2mdoi.6gl.avl@gamma.logic.tuwien.ac.at> <j0g1i4$nus$1@speranza.aioe.org>
In-Reply-To <j0g1i4$nus$1@speranza.aioe.org>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Message-ID <ueidnUcxuMPT2LHTnZ2dnUVZ_uKdnZ2d@earthlink.com> (permalink)
Lines 36
X-Usenet-Provider http://www.giganews.com
NNTP-Posting-Host 70.230.200.239
X-Trace sv3-aDg9Fp1n9MBApxPH01mFLF+haFcWzJuzRLeXVyomRoRAqwBG1HFbeNvHdRoNSEtlayXrbBiVf4DvmG9!h8+7RCapGEw0k1OQ+1D1MEtKMkEVQM9uNWgnGz05oTuXyRShNdyrh7R6JRxrOm64D8hshyHC8TTO!56aYoemchuijJtS9ATdsQJ5z4uR3nb1kETyTyGm6twLn8cI=
X-Abuse-and-DMCA-Info Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info Otherwise we will be unable to process your complaint properly
X-Postfilter 1.3.40
X-Original-Bytes 3950
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6508

Show key headers only | View raw


On 7/23/2011 7:55 PM, Henderson wrote:
> On 23/07/2011 5:03 PM, Andreas Leitgeb wrote:
>> It is my opinion, that operator overloading at least for a certain
>> limited set of JSL classes (including BigDecimal and BigInteger as
>> well as some new Complex class in addition to String's +), would
>> be beneficial. Ditto for a new "strictint" keyword to enable
>> detection and handling of integer overflows.
>
> An obvious suggestion would be to allow it on all java.lang.Number
> subclasses, but a + b among these is only defined if a is a Number class
> that has an overload of .plus(x) that is applicable to an argument of a
> supertype of b, and the most specific such is chosen; and if a is a
> primitive, is treated as b + a; a * b analogously; a - b with a
> primitive uses (b - a).negate() and expects the return type of minus to
> support negate(); and for division we likewise need .reciprocal().
>
> 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.

You cannot return "the value of the specified number as a double" if the
specified number is complex. I would prefer the complex type to have
separate, meaningfully named, methods returning as double each of the
real part, the complex part, the absolute value, and the phase.

I think it might be better to create a marker interface
java.math.Arithmetic. I do like the idea of a fixed mapping from
operators to method names that are normal identifiers. I don't think
all arithmetic types should be required to support all operations. For
example, consider negate and an unsigned type, or reciprocal and an
integer type.

Patricia

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