delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2012/12/18/20:31:18

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-5.9 required=5.0 tests=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.66.79.163 with SMTP id k3mr12038828pax.60.1355880661424; Tue, 18 Dec 2012 17:31:01 -0800 (PST)
Message-ID: <50D118CE.8090108@gmail.com>
Date: Wed, 19 Dec 2012 09:30:54 +0800
From: KHMan <keinhong AT gmail DOT com>
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1
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>
In-Reply-To: <1355878473.91036.YahooMailNeo@web121001.mail.ne1.yahoo.com>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
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 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<math.h>
> #include<stdio.h>
> #include<stdlib.h>
>
> 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.

-- 
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia

--
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019