X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-5.7 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org X-Received: by 10.14.221.9 with SMTP id q9mr12045316eep.3.1355900628282; Tue, 18 Dec 2012 23:03:48 -0800 (PST) Message-ID: <50D166D2.3030505@gmail.com> Date: Wed, 19 Dec 2012 08:03:46 +0100 From: marco atzeri User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: Bug in Cygwin strtod() References: <1355878473 DOT 91036 DOT YahooMailNeo AT web121001 DOT mail DOT ne1 DOT yahoo DOT com> <50D118CE DOT 8090108 AT gmail DOT com> In-Reply-To: <50D118CE.8090108@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com On 12/19/2012 2:30 AM, KHMan wrote: > On 12/19/2012 8:54 AM, Cary R. wrote: >> The following code demonstrates a subtle bug in the Cygwin version of >> strtod(). The value it generates is slightly different than the value >> when using the math header files. This used to work correctly some >> time ago (months). I just took the time to track the problem down in >> our regression suite. >> >> #include >> #include >> #include >> >> int main() >> { >> double value = M_LN10; >> >> printf("generate const. - value: %0.15f.\n", value); >> printf("expected const. - value: 2.302585092994046.\n"); >> >> printf("\n"); >> value = strtod("2.30258509299404568402", 0); >> >> /* Note: the last digit is incorrect. */ >> printf("generate strtod - value: %0.15f.\n", value); >> printf("expected strtod - value: 2.302585092994046.\n"); >> >> return 0; >> } > > Yep, looks like the significand misses its mark by 1. > strtod is from newlib. the last change in the code is one year and half ago http://sourceware.org/cgi-bin/cvsweb.cgi/src/newlib/libc/stdlib/strtod.c.diff?r1=1.17&r2=1.18&cvsroot=src -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple