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

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=0.8 required=5.0 tests=AWL,BAYES_50,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_HOSTKARMA_YE,REPTO_QUOTE_YAHOO,T_RP_MATCHES_RCVD
X-Spam-Check-By: sourceware.org
X-Rocket-MIMEInfo: 001.001,VGhlIGZvbGxvd2luZyBjb2RlIGRlbW9uc3RyYXRlcyBhIHN1YnRsZSBidWcgaW4gdGhlIEN5Z3dpbiB2ZXJzaW9uIG9mIHN0cnRvZCgpLiBUaGUgdmFsdWUgaXQgZ2VuZXJhdGVzIGlzIHNsaWdodGx5IGRpZmZlcmVudCB0aGFuIHRoZSB2YWx1ZSB3aGVuIHVzaW5nIHRoZSBtYXRoIGhlYWRlciBmaWxlcy4gVGhpcyB1c2VkIHRvIHdvcmsgY29ycmVjdGx5IHNvbWUgdGltZSBhZ28gKG1vbnRocykuIEkganVzdCB0b29rIHRoZSB0aW1lIHRvIHRyYWNrIHRoZSBwcm9ibGVtIGRvd24gaW4gb3VyIHJlZ3Jlc3Npb24BMAEBAQE-
Message-ID: <1355878473.91036.YahooMailNeo@web121001.mail.ne1.yahoo.com>
Date: Tue, 18 Dec 2012 16:54:33 -0800 (PST)
From: "Cary R." <cygcary AT yahoo DOT com>
Reply-To: "Cary R." <cygcary AT yahoo DOT com>
Subject: Bug in Cygwin strtod()
To: "cygwin AT cygwin DOT com" <cygwin AT cygwin DOT com>
MIME-Version: 1.0
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
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id qBJ0vRsM005967

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


This code does produce the expected output under Linux and when using the MinGW compilers.

Cary


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