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: Java puzzler Date: Sat, 14 May 2011 15:08:45 -0400 Organization: A noiseless patient Spider Lines: 13 Message-ID: References: <4db69c13-878f-4806-adb2-a3c5adb1c48c@glegroupsg2000goo.googlegroups.com> <-8mdnSRPEIdA21HQnZ2dnUVZ_j2dnZ2d@earthlink.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 14 May 2011 19:08:45 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="3xSaU6y5tAyBQEIxw+DaTw"; logging-data="28855"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/71g9TWtQQyk7tohWMNEFUZQiFMCoHpU8=" User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.16pre) Gecko/20110305 Lightning/1.0b3pre Thunderbird/3.1.10pre In-Reply-To: Cancel-Lock: sha1:M/8pUaPF25RrYns9xXPeVdSjxjE= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:4084 On 05/14/2011 11:09 AM, Patricia Shanahan wrote: > double d = Double.MAX_VALUE; > double e = (d + d) - d; > > The correct result is Double.POSITIVE_INFINITY, not Double.MAX_VALUE. I haven't double-checked, but isn't this only necessarily the case if the method is strictfp? Or does non-strictfp merely only permit extended precision in the mantissa and not the exponent? -- Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald E. Knuth