From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3653 invoked by alias); 21 Jul 2014 18:26:32 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 3587 invoked by uid 55); 21 Jul 2014 18:26:28 -0000 From: "sgk at troutmask dot apl.washington.edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/61847] bug in gfortran runtime on OSX: digits cut off when reading floating point number Date: Mon, 21 Jul 2014 18:26:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 4.8.3 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: sgk at troutmask dot apl.washington.edu X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-07/txt/msg01470.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61847 --- Comment #8 from Steve Kargl --- On Mon, Jul 21, 2014 at 06:18:14PM +0000, e2cd58e1 at opayq dot com wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61847 > > --- Comment #7 from e2cd58e1 at opayq dot com --- > For > > printf("Test 1 = %.4f\n",strtod("1.2345",NULL)); > printf("Test 2 = %.4f\n",strtod("1,2345",NULL)); > > I get > > Test 1 = 1,0000 > Test 2 = 1,2345 > That's what I would expect. Here's another test; #include #include #include int main(void) { char *s1 = "1.2345", *s2 = "5,4321"; double d1, d2; setlocale(LC_ALL, "en_US.ISO8859-1"); d1 = strtod(s1, NULL); d2 = strtod(s2, NULL); printf("%s = %.4lf and %s = %.4lf\n", s1, d1, s2, d2); setlocale(LC_ALL, "de_DE.UTF-8"); d1 = strtod(s1, NULL); d2 = strtod(s2, NULL); printf("%s = %.4lf and %s = %.4lf\n", s1, d1, s2, d2); return 0; } I get troutmask:sgk[204] ./z 1.2345 = 1.2345 and 5,4321 = 5.0000 1.2345 = 1,0000 and 5,4321 = 5,4321 So, the section of code that I posted in comment 6 is ensuring that the fraction separator is always a decimal point, and your locale and strtod are expecting a comma.