Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsfeed.utanet.at!newscore.univie.ac.at!aconews-feed.univie.ac.at!aconews.univie.ac.at!not-for-mail Newsgroups: comp.lang.java.programmer From: Andreas Leitgeb Subject: Re: Arithmetic overflow checking References: <015aeb15-57db-48ab-9cd4-77f8448b632f@w24g2000yqw.googlegroups.com> <1f9c17dltrhlmhifuigoa914477r4rg1e1@4ax.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> Reply-To: avl@logic.at User-Agent: slrn/pre0.9.9-111 (Linux) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: Date: 21 Jul 2011 15:38:08 GMT Lines: 17 NNTP-Posting-Host: gamma.logic.tuwien.ac.at X-Trace: 1311262688 tunews.univie.ac.at 73248 128.130.175.3 X-Complaints-To: abuse@tuwien.ac.at Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6344 lewbloch wrote: > And what about the suggestion to write a CheckedInteger type that does > what you need? That has been answered already, but you may have missed it, or maybe blocked the one who answered this seriously and (imho) agreeably. Due to Java's lack of operator overloading, doing Math with non-primitive types is just painful. PS: my approach would be a new keyword like strictfp (which may modify floating point semantics compared to not-applying it), just one for modifying integral semantics: arithmetic overflow checks and runtime checks on cast to narrower types. Just like use of "strictfp" can be expected to slow down programs, the same would be acceptable for an integral pendant.