Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Joshua Cranmer Newsgroups: comp.lang.java.programmer Subject: Re: Arithmetic overflow checking Date: Tue, 26 Jul 2011 03:28:34 -0400 Organization: A noiseless patient Spider Lines: 32 Message-ID: References: <015aeb15-57db-48ab-9cd4-77f8448b632f@w24g2000yqw.googlegroups.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> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 26 Jul 2011 07:28:38 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="bAymlyY9SkaJNa8Tz2rerw"; logging-data="689"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/enPkppUkRRPAD2YZyrUKMf8MpXMxiGu4=" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7 In-Reply-To: Cancel-Lock: sha1:X05WUB67eimrd3mWaJLEw02eim8= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6567 On 7/25/2011 11:12 AM, Henderson wrote: > Until some enterprising mathematician thinks up something that can be > added and multiplied, but has no sensible correspondence to any subset > of any kind of vectors of real numbers ... You've never taken abstract algebra, have you? Polynomials are the most common counterexample I can think of (although they are treatable as an infinite vector space over any finite field). You can also generalize functions over the real numbers as a ring, and I'd find it hard pressed to come up with a scheme that can sensibly "correspond to any subset of any kind of vectors of real numbers" that can handle things as wildly varying as f(x) = 1, f(x) = sin x, f(x) = integral from 0 to x of exp(-t^2) dt, f(x) = 1 if x is rational and 1/x if x is irrational, or f(x) = sum from n = 0 to infinity of 1/2 ^n cos(9^n pi x) (the Weierstrass function). Of course, if you just want addition, I can pull any old group out of a hat. Symmetries of an n-gon are a particular favorite example for nonabelian groups, as are permutations of sets. > I think you can cram matrices in there, and complex numbers. Numbers mod > something, too -- though do you quietly truncate when converting to > these, or throw an exception? Of course, primitive int is already > actually an integers-mod-2^32 type so that may be considered already > settled. What do you mean by "truncate" in modular arithmetic? Mod 10, 1 and 11 are the same thing (the set of numbers {..., -9, 1, 11, ... }). -- Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald E. Knuth