Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: markspace <-@.> Newsgroups: comp.lang.java.programmer Subject: Re: higher precision doubles Date: Sat, 06 Aug 2011 13:29:41 -0700 Organization: A noiseless patient Spider Lines: 44 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 6 Aug 2011 20:29:49 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="XjIWM99mD7Ijfdu600oVPA"; logging-data="21269"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19r7uikUjvoxnEco7LG3EJaWf1eLZORG+U=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20110624 Thunderbird/5.0 In-Reply-To: Cancel-Lock: sha1:DiIRavwDykwifNE3xWnBGndFsy4= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6830 On 8/6/2011 12:24 PM, Jan Burse wrote: > Motivating example, in Go we have: ... > In Java we have: ... > zero1=-2.4492935982947064E-16 > zero2=-2.4492935982947064E-16 I honestly don't find this very motivating. Zero is what you make of it. In engineering I learning that 6 digits are sufficient for almost any practical task. 30 is way overkill. As far as printing is concerned, don't get confused by the funny numbers. It's just a matter of understanding and selecting the correct format. Counter motivating example: public class FpPrint { public static void main( String[] args ) { System.out.printf( "%6.6f\n", Math.sin( Math.PI * 2 ) ); System.out.printf( "%6.6f\n", StrictMath.sin( StrictMath.PI * 2 ) ); } } run: -0.000000 -0.000000 BUILD SUCCESSFUL (total time: 0 seconds) Here we understand what significant digits mean, and we print the correct and desired number of digits. We're good. There's many times many accumulated errors between 0 and 2 x 10^-16 . Just because the default Java printer doesn't print a "0" doesn't mean we should panic. That's really all your demonstrating here: the default printing behavior of System.out.println.