develooper Front page | perl.perl5.porters | Postings from January 2012

[perl #109318] Broken atof

From:
Bo Lindbergh
Date:
January 30, 2012 02:45
Subject:
[perl #109318] Broken atof
Message ID:
rt-3.6.HEAD-14510-1327861480-279.109318-75-0@perl.org
# New Ticket Created by  Bo Lindbergh 
# Please include the string:  [perl #109318]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=109318 >


This is a bug report for perl from blgl@stacken.kth.se,
generated with the help of perlbug 1.39 running under perl 5.15.7.


-----------------------------------------------------------------
[Please describe your issue here]

use strict;
use warnings;
use POSIX;
use locale;

setlocale(LC_NUMERIC,"sv_SE");

printf("%g\n","3.14e+9");       # prints "3,14e+09\n"
printf("%g\n","3,14e+9");       # prints "3,14e+09\n"
printf("%g\n","3.14e-9");       # prints "3,14e-09\n"
printf("%g\n","3,14e-9");       # prints "3\n"          *** WRONG! ***

# Perl_my_atof tries to be clever with locale decimal separators
# and falls on its face:
#        /* Scan the number twice; once using locale and once without;
#         * choose the larger result (in absolute value). */
# This heuristic fails for negative exponents.

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=medium
---
Site configuration information for perl 5.15.7:

Configured by blgl at Sun Jan 29 18:19:04 CET 2012.

Summary of my perl5 (revision 5 version 15 subversion 7) configuration:
   
  Platform:
    osname=darwin, osvers=10.8.0, archname=darwin-2level
    uname='darwin localhost.local 10.8.0 darwin kernel version 10.8.0: tue jun 7 16:33:36 pdt 2011; root:xnu-1504.15.3~1release_i386 i386 '
    config_args=''
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include',
    optimize='-Os',
    cppflags='-fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.2.1 (Apple Inc. build 5666) (dot 3)', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib
    libs=-lutil -lc
    perllibs=-lutil -lc
    libc=, so=dylib, useshrplib=false, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/usr/local/lib -fstack-protector'

Locally applied patches:
    

---
@INC for perl 5.15.7:
    /usr/unstable/lib/perl5/site_perl/5.15.7/darwin-2level
    /usr/unstable/lib/perl5/site_perl/5.15.7
    /usr/unstable/lib/perl5/5.15.7/darwin-2level
    /usr/unstable/lib/perl5/5.15.7
    .

---
Environment for perl 5.15.7:
    DYLD_LIBRARY_PATH (unset)
    HOME=/Users/blgl
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/Users/blgl/bin:/Users/blgl/bin/powerpc-apple-darwin:/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin
    PERL_BADLANG (unset)
    SHELL=/bin/tcsh




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About