Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: "Nasser M. Abbasi" Newsgroups: comp.lang.java.programmer Subject: Re: higher precision doubles Date: Sat, 10 Sep 2011 21:53:40 -0700 Organization: Aioe.org NNTP Server Lines: 34 Message-ID: References: Reply-To: nma@12000.org NNTP-Posting-Host: 4IuMaYl5j9Y5F74I990LJw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20110902 Thunderbird/6.0.2 X-Notice: Filtered by postfilter v. 0.8.2 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:7779 On 8/6/2011 12:24 PM, Jan Burse wrote: > > > Motivating example, in Go we have: > > func main() { > x := math.Sin(2*math.Pi) > fmt.Printf("x = %.30f, is zero = %v\n", x, x == 0) > } > > x = 0.000000000000000000000000000000, is zero = true > > In Java we have: > ... > > > zero1=-2.4492935982947064E-16 > zero2=-2.4492935982947064E-16 Well, both as not correct :) Here is the correct math answer Mathematica: x = Sin[2 Pi] 0 An exact zero. As was created by God. Not a floating point zero. --Nasser