Skip Menu |
 

This queue is for tickets about the Math-BigInt CPAN distribution.

Report information
The Basics
Id: 43692
Status: resolved
Priority: 0/
Queue: Math-BigInt

People
Owner: Nobody in particular
Requestors: emazep [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.89
Fixed in: (no value)



Subject: For some values of x, blog(x) returns blog(2*x) when the accuracy is >= 71
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Charset: utf8
X-RT-Original-Encoding: utf-8
Content-Type: multipart/mixed; boundary="----------=_1235726136-31384-193"
Content-Length: 0
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
Content-Length: 686
Download (untitled) / with headers
text/plain 686b
Consider the following code snippet: --- use Math::BigFloat; my $x = Math::BigFloat->new(15); $x->accuracy(70); print $x->copy->blog, "\n"; # 2.7... $x->accuracy(71); print $x->blog, "\n"; # 3.4... --- the first print produces 2.7... (which is correct) while, once increased the accuracy from 70 to 71, the second print produces 3.4..., which is wrong ( it actually is log(2*$x) - or log($x)+log(2) ). It happens only for some values of $x (e.g. 11..19, but also for very big numbers). Attached is a new test file (accuracy_biglog.t - which tries to adhere to the Math::BigInt test standards) containing a failing test. Thanks for your invaluable work, Emanuele Zeppieri
Subject: perl-V.txt
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----------=_1235725615-31384-191"
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Charset: utf8
Content-Length: 0
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: iso-8859-1
Content-Length: 0
Content-Type: text/plain; charset="utf-8"; name="perl-V.txt"
Content-Disposition: inline; filename="perl-V.txt"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: ascii
Content-Length: 2758
Download perl-V.txt
text/plain 2.6k
Summary of my perl5 (revision 5 version 10 subversion 0 patch 34065) configuration: Platform: osname=cygwin, osvers=1.5.25(0.15642), archname=cygwin-thread-multi-64int uname='cygwin_nt-5.1 reini 1.5.25(0.15642) 2008-06-12 19:34 i686 cygwin ' config_args='-de -Dmksymlinks -Dusethreads -Dmad=y -Dusedevel' hint=recommended, useposix=true, d_sigaction=define useithreads=define, usemultiplicity=define useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef use64bitint=define, use64bitall=undef, uselongdouble=undef usemymalloc=y, bincompat5005=undef Compiler: cc='gcc', ccflags ='-DPERL_USE_SAFE_PUTENV -U__STRICT_ANSI__ -fno-strict-aliasing -pipe -I/usr/local/include', optimize='-O3', cppflags='-DPERL_USE_SAFE_PUTENV -U__STRICT_ANSI__ -fno-strict-aliasing -pipe -I/usr/local/include' ccversion='', gccversion='3.4.4 (cygming special, gdc 0.12, using dmd 0.125)', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='g++', ldflags =' -Wl,--enable-auto-import -Wl,--export-all-symbols -Wl,--stack,8388608 -Wl,--enable-auto-image-base -L/usr/local/lib' libpth=/usr/local/lib /usr/lib /lib libs=-lgdbm -ldb -ldl -lcrypt -lgdbm_compat perllibs=-ldl -lcrypt libc=/usr/lib/libc.a, so=dll, useshrplib=true, libperl=libperl.a gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags=' --shared -Wl,--enable-auto-import -Wl,--export-all-symbols -Wl,--stack,8388608 -Wl,--enable-auto-image-base -L/usr/local/lib' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY MYMALLOC PERL_DONT_CREATE_GVSV PERL_IMPLICIT_CONTEXT PERL_MAD PERL_MALLOC_WRAP PERL_USE_SAFE_PUTENV USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES USE_PERLIO USE_REENTRANT_API Locally applied patches: MAINT34065 CYG11 no-bs CYG12 no archlib in otherlibdirs CYG14 Dynaloader CYG15 static-Win32CORE Bug#55162 File::Spec::case_tolerant performance Built under cygwin Compiled at Jun 30 2008 16:05:15 %ENV: CYGWIN="" @INC: /usr/lib/perl5/5.10/i686-cygwin /usr/lib/perl5/5.10 /usr/lib/perl5/site_perl/5.10/i686-cygwin /usr/lib/perl5/site_perl/5.10 /usr/lib/perl5/vendor_perl/5.10/i686-cygwin /usr/lib/perl5/vendor_perl/5.10 /usr/lib/perl5/vendor_perl/5.10 /usr/lib/perl5/site_perl/5.8 /usr/lib/perl5/vendor_perl/5.8 .
Subject: accuracy_biglog.t
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----------=_1235726037-31384-192"
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Charset: utf8
Content-Length: 0
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: iso-8859-1
Content-Length: 0
Content-Type: application/octet-stream; name="accuracy_biglog.t"
Content-Disposition: inline; filename="accuracy_biglog.t"
Content-Transfer-Encoding: base64
Content-Length: 939
Download accuracy_biglog.t
text/x-perl 939b
#!/usr/bin/perl -w # Emanuele Zeppieri # # Failing test for a bug in 1.89 which causes blog(x) to return blog(x)+blog(2) # for some values of x, when the accuracy is >= 71. use Test::More; use strict; BEGIN { $| = 1; # to locate the testing files my $location = $0; $location =~ s/bigroot.t//i; if ($ENV{PERL_CORE}) { # testing with the core distribution @INC = qw(../lib); } unshift @INC, '../lib'; if (-d 't') { chdir 't'; require File::Spec; unshift @INC, File::Spec->catdir(File::Spec->updir, $location); } else { unshift @INC, $location; } print "# INC = @INC\n"; plan tests => 1; } use Math::BigFloat; my $cl = "Math::BigFloat"; ############################################################################# # test blog(x,a) with the failing values x=15 and a=71 like ($cl->new(15)->blog(undef,71), qr/^2\.7080502011022100659960045701487133/); # all done
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-25792-1341855209-435.43692-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 247
Download (untitled) / with headers
text/plain 247b
This is still a problem on the latest version. Even this fails: use Math::BigFloat; my $x = Math::BigFloat->new(15); print $x->copy->blog(undef, 70), "\n"; # 2.7... $x = Math::BigFloat->new(15); print $x->copy->blog(undef, 71), "\n"; # 3.4...
MIME-Version: 1.0
In-Reply-To: <rt-3.8.HEAD-25792-1341855209-435.43692-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
X-RT-Interface: Web
References: <rt-3.8.HEAD-25792-1341855209-435.43692-0-0 [...] rt.cpan.org>
Content-Type: multipart/mixed; boundary="----------=_1382466041-11782-2"
Message-ID: <rt-4.0.16-11782-1382466041-1134.43692-0-0 [...] rt.cpan.org>
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 0
Content-Disposition: inline
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 404
Download (untitled) / with headers
text/plain 404b
Attached is a patch that fixes this. It would be nice to have someone else review this. It passes the current test suite as well as fixing the issues shown in RT 43692 and RT 77105 as well as some Riemann Zeta code I have that is brutalized by this RT. With high accuracy, we were adding in $l_2 to the result even if $twos was 0. The fix is to undefine $l2 when $twos is zero, so it is not added in.
MIME-Version: 1.0
Subject: bigfloat-log-fix.patch
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Type: text/x-patch; name="bigfloat-log-fix.patch"
Content-Disposition: inline; filename="bigfloat-log-fix.patch"
Content-Transfer-Encoding: binary
Content-Length: 388
--- lib/Math/BigFloat.pm.orig 2013-10-22 10:55:47.640415285 -0700 +++ lib/Math/BigFloat.pm 2013-10-22 11:16:38.744412163 -0700 @@ -1498,6 +1498,10 @@ } $l_2->bmul($twos); # * -2 => subtract, * 2 => add } + else + { + undef $l_2; + } $self->_log($x,$scale); # need to do the "normal" way $x->badd($l_10) if defined $l_10; # correct it by ln(10)
MIME-Version: 1.0
In-Reply-To: <rt-4.0.16-11782-1382466041-1134.43692-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
X-RT-Interface: Web
References: <rt-3.8.HEAD-25792-1341855209-435.43692-0-0 [...] rt.cpan.org> <rt-4.0.16-11782-1382466041-1134.43692-0-0 [...] rt.cpan.org>
Content-Type: multipart/mixed; boundary="----------=_1382467069-11775-3"
Message-ID: <rt-4.0.16-11775-1382467069-1411.43692-0-0 [...] rt.cpan.org>
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 0
Content-Disposition: inline
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 163
Download (untitled) / with headers
text/plain 163b
Here is an alternate patch which does the same thing, but in this case it removes $l_2 immediately after using it to compute the high-accuracy $l_10. Your choice.
MIME-Version: 1.0
Subject: bigfloat-log-fix.patch
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Type: text/x-patch; name="bigfloat-log-fix.patch"
Content-Disposition: inline; filename="bigfloat-log-fix.patch"
Content-Transfer-Encoding: binary
Content-Length: 409
--- lib/Math/BigFloat.pm.orig 2013-10-22 10:55:47.640415285 -0700 +++ lib/Math/BigFloat.pm 2013-10-22 11:36:05.948409256 -0700 @@ -1443,6 +1443,7 @@ $l_10->badd($l_2); $l_10->badd($l_2); $l_10->badd($l_2); + undef $l_2; # done with l_2 $LOG_10 = $l_10->copy(); # cache the result for later # the copy() is for mul below $LOG_10_A = $scale;
MIME-Version: 1.0
In-Reply-To: <rt-4.0.16-11775-1382467069-1411.43692-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <rt-3.8.HEAD-25792-1341855209-435.43692-0-0 [...] rt.cpan.org> <rt-4.0.16-11782-1382466041-1134.43692-0-0 [...] rt.cpan.org> <rt-4.0.16-11775-1382467069-1411.43692-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-6356-1397577670-250.43692-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 78
MIME-Version: 1.0
In-Reply-To: <rt-4.0.18-6356-1397577670-250.43692-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <rt-3.8.HEAD-25792-1341855209-435.43692-0-0 [...] rt.cpan.org> <rt-4.0.16-11782-1382466041-1134.43692-0-0 [...] rt.cpan.org> <rt-4.0.16-11775-1382467069-1411.43692-0-0 [...] rt.cpan.org> <rt-4.0.18-6356-1397577670-250.43692-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-4662-1401132977-257.43692-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 290
Download (untitled) / with headers
text/plain 290b
On Tue Apr 15 12:01:10 2014, pjacklam wrote: Show quoted text
> Patch submitted upstream as > > https://rt.perl.org/Ticket/Display.html?id=121666
Thanks! I noticed it is marked important in this RT (since it breaks a number of math operations with no workaround possible), but severity low for Perl's RT.
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-27921-1401866547-818.43692-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 76
MIME-Version: 1.0
X-Spam-Status: No, score=-4.699 tagged_above=-99.9 required=10 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, FROM_OUR_RT=-2, RCVD_IN_DNSWL_LOW=-0.7] autolearn=ham
In-Reply-To: <rt-4.0.18-27921-1401866549-1862.43692-10-0 [...] rt.cpan.org>
X-Spam-Flag: NO
X-RT-Interface: API
References: <RT-Ticket-43692 [...] rt.cpan.org> <rt-4.0.18-27921-1401866549-1862.43692-10-0 [...] rt.cpan.org>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
X-Received: by 10.14.184.130 with SMTP id s2mr141109eem.34.1401869867703; Wed, 04 Jun 2014 01:17:47 -0700 (PDT)
Message-ID: <538ED629.1030709 [...] gmail.com>
content-type: text/plain; charset="utf-8"
X-RT-Original-Encoding: utf-8
X-Spam-Score: -4.699
Authentication-Results: hipster.bestpractical.com (amavisd-new); dkim=pass header.i= [...] gmail.com
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id D143A2409C0 for <cpan-bug+Math-BigInt [...] hipster.bestpractical.com>; Wed, 4 Jun 2014 04:17:56 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7hXF73lVP9tY for <cpan-bug+Math-BigInt [...] hipster.bestpractical.com>; Wed, 4 Jun 2014 04:17:56 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id BAF112409BD for <bug-Math-BigInt [...] rt.cpan.org>; Wed, 4 Jun 2014 04:17:55 -0400 (EDT)
Received: (qmail 16287 invoked by alias); 4 Jun 2014 08:17:54 -0000
Received: from mail-we0-f182.google.com (HELO mail-we0-f182.google.com) (74.125.82.182) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Wed, 04 Jun 2014 01:17:52 -0700
Received: by mail-we0-f182.google.com with SMTP id t60so7895194wes.41 for <bug-Math-BigInt [...] rt.cpan.org>; Wed, 04 Jun 2014 01:17:47 -0700 (PDT)
Received: from [192.168.1.20] (ppp-56-116.24-151.libero.it. [151.24.116.56]) by mx.google.com with ESMTPSA id z44sm3989592eep.39.2014.06.04.01.17.46 for <bug-Math-BigInt [...] rt.cpan.org> (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 04 Jun 2014 01:17:46 -0700 (PDT)
Delivered-To: cpan-bug+Math-BigInt [...] hipster.bestpractical.com
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.5.0
Subject: Re: [rt.cpan.org #43692] Resolved: For some values of x, blog(x) returns blog(2*x) when the accuracy is >= 71
Return-Path: <emazep [...] gmail.com>
Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=m2p+JPY86O/9JlZJm4L0jghy/AGwar9l3LmnkHkPTYo=; b=DbB1oOJeonca956Wxzazr72Q9tR3fLyoFWnjVOI4wg2j6zQIuZjbt4Lc5uAxtZzPIh ul2891+PjB3fw2NAmUrqJg4Ot71hP7rdREc6KG8xas1dL3Hog4lYaOHPg39HIZYNPVAX IzRBk5lRYfYd5nMtXLAJEaTLLd0ysO3RA/wWdIVb0qcahtuSMOSyxaf8GRo5lgVU0ZR1 xiD6aw5HLkZvVt2//WuU71GoiEkxQB5sLr/aKA7/SiCPchbykkRRWnBLv0LkFwrwaYzA bWgTH4XL6yhJoel98IuLXV0vfXAZRLR+1YxjeSSNdayBqMBUP9P48hhsENtMeCHmRn/Y QF8g==
X-Spam-Check-BY: la.mx.develooper.com
X-Original-To: cpan-bug+Math-BigInt [...] hipster.bestpractical.com
X-RT-Mail-Extension: math-bigint
Date: Wed, 04 Jun 2014 10:17:45 +0200
X-Spam-Level:
To: bug-Math-BigInt [...] rt.cpan.org
Content-Transfer-Encoding: 7bit
From: Emanuele Zeppieri <emazep [...] gmail.com>
RT-Message-ID: <rt-4.0.18-25689-1401869877-1643.43692-0-0 [...] rt.cpan.org>
Content-Length: 305
Download (untitled) / with headers
text/plain 305b
Thank you all, especially to DANAJ. -Emanuele On 2014-06-04 09:22, Peter John Acklam via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=43692 > > > According to our records, your request has been resolved. If you have any > further questions or concerns, please respond to this message.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.