Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!news.glorb.com!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Sat, 14 May 2011 15:25:49 -0500 Date: Sat, 14 May 2011 13:25:48 -0700 From: Patricia Shanahan User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: Java puzzler References: <4db69c13-878f-4806-adb2-a3c5adb1c48c@glegroupsg2000goo.googlegroups.com> <-8mdnSRPEIdA21HQnZ2dnUVZ_j2dnZ2d@earthlink.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Lines: 18 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 75.8.126.96 X-Trace: sv3-iDdi/QQokMzLhczU8Lq87ysyffWurNUn89Cv3qAFJsT1RYwmyJ/5S9mCM0IH5hFbCvsFyOSFXBG/73O!yqR+fW3MVk9HAUiIDmeiJN8aSaPyhx/BLB8kJd1OdpnSEVMF8nyvSFV3YDhkxZyOeOc7asRYZ95D!VBevgn0LLrXEG69+Z8cX1n8pewTEefu2wBFALV80ysQ= X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2385 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:4087 On 5/14/2011 12:08 PM, Joshua Cranmer wrote: > 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? > Good point. If the expression is not strictfp, the addition result can be expressed in the double-extended-exponent value set, which allows for a finite answer. Patricia