Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!novia!news-out.readnews.com!news-xxxfer.readnews.com!nx02.iad01.newshosting.com!newshosting.com!69.16.185.21.MISMATCH!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!newsfe08.iad.POSTED!00000000!not-for-mail From: David Lamb User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.18) Gecko/20110616 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> <2rydnez7l-H5BYnTnZ2dnUVZ_vGdnZ2d@earthlink.com> <4e278a67$0$309$14726298@news.sunsite.dk> <1SSVp.69032$_I7.18660@newsfe08.iad> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Lines: 20 Message-ID: NNTP-Posting-Host: 67.193.237.254 X-Complaints-To: abuse@cogeco.net X-Trace: newsfe08.iad 1311434631 67.193.237.254 (Sat, 23 Jul 2011 15:23:51 UTC) NNTP-Posting-Date: Sat, 23 Jul 2011 15:23:51 UTC Date: Sat, 23 Jul 2011 11:23:47 -0400 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6451 On 21/07/2011 8:32 AM, Andreas Leitgeb wrote: > supercalifragilisticexpialadiamaticonormalizeringelimatisticantations wrote: >> On 21/07/2011 6:05 AM, Arved Sandstrom wrote: >>> ... Why don't you write a proper class for your data type? >> In four words: Lack of operator overloading. >> Math on non-primitive types is *painful* in Java. > > agreeCount = agreeCount.plus(AgreeCount.ONE) > on painfulness of non-primitive math. > or if you think ++ is common enough: agreeCount.increment(); and generally agreeCount.add(someOtherAgreeCount) and if you decide to have your operators return "this" ac0.mul(ac1).plus(ac2)) // ac0 = ac0*ac1+ac2 or ac = (new AgreeCount(ac0)).mul(ac1).plus(ac2) // ac = ac0*ac1+ac2