Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!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 11:35:51 -0400 Organization: A noiseless patient Spider Lines: 15 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 15:35:51 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="bAymlyY9SkaJNa8Tz2rerw"; logging-data="11470"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19YkqeGW7vdKmi7hJ4r+wT3A19wSX3DNek=" User-Agent: Mozilla/5.0 (X11; Linux i686; rv:5.0) Gecko/20110715 Thunderbird/5.0b2pre In-Reply-To: Cancel-Lock: sha1:c6pyIok0NsmfvfgjLoS9YiVsqjI= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6577 On 07/26/2011 04:53 AM, Henderson wrote: > On 26/07/2011 3:28 AM, Joshua Cranmer wrote: >> 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, ... }). > > As in, if you have a mod10 type, and you assign 36 to it, do you just > silently accept that and store it internally as 6, or do you throw an > exception if the input isn't in the range 0 to 9? There is nothing inherently correct about the elements in mod 10 arithmetic having values 0 to 9, so 36 is as valid in mod 10 as 6 is. -- Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald E. Knuth