[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]
[perl #59386] float modification with regex non-substition
# New Ticket Created by marc.pack@computer.org
# Please include the string: [perl #59386]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=59386 >
This is a bug report for perl from marc.pack@computer.org,
generated with the help of perlbug 1.35 running under perl v5.8.7.
-----------------------------------------------------------------
[Please enter your report here]
I've searched the FAQ and database and haven't found a reference to this
(hopefully obscure) bug. The problem occurs when I do a regular
expression substution on a float variable, where the substitution
doesn't change anything but the variable is modfied nonetheless.
The following invocation and output demonstrates the problem:
perl -e 'my $f = 123456789.123456789;
printf("%.10f\n",$f);
$f =~ s/^\s*|\s*$//g;
printf("%.10f\n", $f);'
123456789.1234567910
123456789.1234569997
Although no change should have occurred because $f doesn't contain any
white space, the variable now has a new, different value.
I'm guessing the internal code goes something like this:
float_string = stringify(float)
if ( float_string contains left_regex ) # which it does; zero or more spaces
substitute_right_regex(float_string)
float = floatify(float_string) # inaccurate float conversion
Of course I understand the problem of text representations of floating
point numbers, but I don't think that an (essentially) no-op substitution
should change the original float.
Thanks for all your work in making a great language even better,
Marc Pack
marc.pack@computer.org
p.s. I already changed the substitution to use \s+, so my problem is
solved, but I thought you'd like to hear about this situation nonetheless.
p.p.s. Sorry I couldn't test a more recent version of Perl (there were
none available to me), but I'm hoping the obscurity of the problem
is such that I'm not wasting your time.
[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
category=core
severity=low
---
Site configuration information for perl v5.8.7:
Configured by pray at Thu May 11 08:37:18 PDT 2006.
Summary of my perl5 (revision 5 version 8 subversion 7) configuration:
Platform:
osname=linux, osvers=2.6.9-34.elsmp, archname=i686-linux
uname='linux branch.jpl.nasa.gov 2.6.9-34.elsmp #1 smp fri feb 24 16:54:53 est 2006 i686 athlon i386 gnulinux '
config_args='-Dcc=/usr/bin/gcc -Dprefix=/dsw/perl-5.8.7'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='/usr/bin/gcc', ccflags ='-DDEBUGGING -fno-strict-aliasing -pipe -I/tps/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
optimize='-g -O2',
cppflags='-DDEBUGGING -fno-strict-aliasing -pipe -I/tps/include -I/usr/include/gdbm'
ccversion='', gccversion='3.4.5 20051201 (Red Hat 3.4.5-2)', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld='/usr/bin/gcc', ldflags =''
libpth=/tps/lib /lib /usr/lib
libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
libc=/lib/libc-2.3.4.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.3.4'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
cccdlflags='-fpic', lddlflags='-shared'
Locally applied patches:
---
@INC for perl v5.8.7:
/dsw/perl-5.8.7/lib/5.8.7/i686-linux
/dsw/perl-5.8.7/lib/5.8.7
/dsw/perl-5.8.7/lib/site_perl/5.8.7/i686-linux
/dsw/perl-5.8.7/lib/site_perl/5.8.7
/dsw/perl-5.8.7/lib/site_perl
.
---
Environment for perl v5.8.7:
HOME=/home/mpack
LANG=en_US.UTF-8
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=.:/home/mpack/CoUGAR/bin:/home/mpack/bin:/tps/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin
PERL_BADLANG (unset)
SHELL=/bin/tcsh
- Follow-Ups from:
-
"Eric Brine" <ikegami@adaelis.com>
[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]