Skip Menu |
 
rt.cpan.org will be shut down on March 1st, 2021.

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

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

People
Owner: Nobody in particular
Requestors: turtle [...] think-electric.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 1.997
Fixed in: 1.9995



Subject: Can no longer subtract an undefined value.
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 982
Download (untitled) / with headers
text/plain 982b
As elegantly reported here: http://lists.opensuse.org/opensuse-bugs/2012-06/msg01204.html You can no longer subtract an undefined value. # perl -e 'use bigint; 5 + $x;' # perl -e 'use bigint; $x - 5;' # perl -e 'use bigint; 5 - $x;' Can't call method "is_zero" on an undefined value at /usr/lib/perl5/5.16.0/Math/BigInt.pm line 1200. I did a little experimenting of my own in BigInt.pm and by reverting only sub objectify to my previous version 1.993 The I narrowed it down to this tiny patch: --- BigInt-b.pm 2012-10-12 21:55:30.102263313 -0700 +++ BigInt.pm 2012-10-12 22:42:33.163394429 -0700 @@ -2669,9 +2669,9 @@ # Don't do anything with undefs. - unless (defined($a[$i])) { - next; - } + #unless (defined($a[$i])) { + # next; + #} # Perl scalars are fed to the appropriate constructor. Which then gives me perl -e 'use bigint; print 5 - $x;' 5 As expected. PS Thanks for your exelent work!
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-18526-1383248250-1954.80162-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: 982
Download (untitled) / with headers
text/plain 982b
How about this as an alternate, replacing the skip undefs: # Warn with undefs, but treat them as zero if (!defined ($a[$i]) && warnings::enabled('uninitialized')) { require Carp; Carp::carp ("Use of uninitialized value in Math::BigInt expression"); } This gives more similar behavior to the non-bigint case. Without warnings on, it should produce the same results (we turn undefs into zero). With warnings, it will produce the "Use of uninitialized value" warning and use zero, just like the non-bigint case. There are some situations where we don't get a warning, e.g. "say $x % 5". I think this is generally a better outcome than (1) different behavior from non-bigint (2) inconsistent behavior: $x % 5 works, but 5 % $x does not 5 ^ $x produces NaN and no warning/error, $x^5 produces 5 (3) screwy error messages, e.g.: Can't call method "is_zero" on an undefined value at ... Can't call method "is_nan" on unblessed reference at ...
From turtle [...] think-electric.com Sun Nov 3 01: 36:50 2013
MIME-Version: 1.0
X-Spam-Status: No, score=-7 tagged_above=-99.9 required=10 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_HI=-5] autolearn=ham
In-Reply-To: <rt-4.0.18-18526-1383248250-950.80162-6-0 [...] rt.cpan.org>
X-Spam-Flag: NO
X-RT-Interface: API
References: <RT-Ticket-80162 [...] rt.cpan.org> <rt-4.0.18-18526-1383248250-950.80162-6-0 [...] rt.cpan.org>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
Message-ID: <c968d4cdd4e2bd1f031dbceff01680e1.squirrel [...] webmail.think-electric.com>
content-type: text/plain; charset="utf-8"
X-RT-Original-Encoding: utf-8
X-Spam-Score: -7
Authentication-Results: hipster.bestpractical.com (amavisd-new); dkim=pass header.i= [...] think-electric.com
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id 3E6E9240982 for <cpan-bug+Math-BigInt [...] hipster.bestpractical.com>; Sun, 3 Nov 2013 01:36:50 -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 hEbHUN+903sF for <cpan-bug+Math-BigInt [...] hipster.bestpractical.com>; Sun, 3 Nov 2013 01:36:48 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id C27172406DA for <bug-Math-BigInt [...] rt.cpan.org>; Sun, 3 Nov 2013 01:36:47 -0400 (EDT)
Received: (qmail 14609 invoked by alias); 3 Nov 2013 05:36:46 -0000
Received: from caibbdcaaaaf.dreamhost.com (HELO homiemail-a78.g.dreamhost.com) (208.113.200.5) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Sat, 02 Nov 2013 22:36:41 -0700
Received: from homiemail-a78.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a78.g.dreamhost.com (Postfix) with ESMTP id 3621F20004746 for <bug-Math-BigInt [...] rt.cpan.org>; Sat, 2 Nov 2013 22:36:37 -0700 (PDT)
Received: from webmail.think-electric.com (caiajhbihbdd.dreamhost.com [208.97.187.133]) (Authenticated sender: turtle [...] think-electric.com) by homiemail-a78.g.dreamhost.com (Postfix) with ESMTPA id DD97E20004741 for <bug-Math-BigInt [...] rt.cpan.org>; Sat, 2 Nov 2013 22:36:36 -0700 (PDT)
Received: from 66.178.130.205 (proxying for 66.178.130.205) (SquirrelMail authenticated user turtle [...] think-electric.com) by webmail.think-electric.com with HTTP; Sat, 2 Nov 2013 22:36:37 -0700
Delivered-To: cpan-bug+Math-BigInt [...] hipster.bestpractical.com
Subject: Re: [rt.cpan.org #80162] Can no longer subtract an undefined value.
User-Agent: SquirrelMail/1.4.21
Return-Path: <turtle [...] think-electric.com>
Dkim-Signature: v=1; a=rsa-sha1; c=relaxed; d=think-electric.com; h= message-id:in-reply-to:references:date:subject:from:to :mime-version:content-type:content-transfer-encoding; s= think-electric.com; bh=YoRQ2UHL9sC/X6GOKGOiE/eLI7Y=; b=Z/7tRaEkK zUctYm4RINK4aXw62F250k4PE18Mo8f+9j9FMdiutrE/+3pbu4pckmOZbDPsCfpO deX9foiIT13CfQQP6ZBTZLhJIG/HCXQAHzzOBC5063a5nEeVr5U1KcA6JZhSz0WU m8tn7OmbBqGLireb23niRhIMl70abKgzXg=
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: Sat, 2 Nov 2013 22:36:37 -0700
X-Spam-Level:
To: bug-Math-BigInt [...] rt.cpan.org
Content-Transfer-Encoding: quoted-printable
From: turtle [...] think-electric.com
RT-Message-ID: <rt-4.0.18-23862-1383457010-283.80162-0-0 [...] rt.cpan.org>
Content-Length: 1115
Excellent I approve Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=80162 > > > How about this as an alternate, replacing the skip undefs: > > # Warn with undefs, but treat them as zero > if (!defined ($a[$i]) && warnings::enabled('uninitialized')) { > require Carp; > Carp::carp ("Use of uninitialized value in Math::BigInt > expression"); > } > > This gives more similar behavior to the non-bigint case. Without warnings > on, it should produce the same results (we turn undefs into zero). With > warnings, it will produce the "Use of uninitialized value" warning and use > zero, just like the non-bigint case. > > There are some situations where we don't get a warning, e.g. "say $x % 5". > > I think this is generally a better outcome than > > (1) different behavior from non-bigint > > (2) inconsistent behavior: > $x % 5 works, but 5 % $x does not > 5 ^ $x produces NaN and no warning/error, $x^5 produces 5 > > (3) screwy error messages, e.g.: > Can't call method "is_zero" on an undefined value at ... > Can't call method "is_nan" on unblessed reference at ... >
MIME-Version: 1.0
In-Reply-To: <rt-4.0.18-23862-1383457010-283.80162-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <RT-Ticket-80162 [...] rt.cpan.org> <rt-4.0.18-18526-1383248250-950.80162-6-0 [...] rt.cpan.org> <c968d4cdd4e2bd1f031dbceff01680e1.squirrel [...] webmail.think-electric.com> <rt-4.0.18-23862-1383457010-283.80162-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-23833-1439809707-1169.80162-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: 598
Download (untitled) / with headers
text/plain 598b
This patch will give a warning when executing something like the following, which computes the logarithm of 2 in the default base (Euler's constant) and rounds the result to 8 digits: $ perl -MMath::BigFloat -wle 'print Math::BigFloat -> new("2") -> blog(undef, 8)' 0.69314718 The problem is that Math::Big(Int|Float) and big(int|num) have differing semantics, and one can not make Math::BigInt::objectify() handle both. I think we have to come up with a different solution to this problem. The first that pops into my mind is to handle this though use of the "overload" package in big(int|num).
MIME-Version: 1.0
In-Reply-To: <rt-4.0.18-23833-1439809707-1169.80162-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <RT-Ticket-80162 [...] rt.cpan.org> <rt-4.0.18-18526-1383248250-950.80162-6-0 [...] rt.cpan.org> <c968d4cdd4e2bd1f031dbceff01680e1.squirrel [...] webmail.think-electric.com> <rt-4.0.18-23862-1383457010-283.80162-0-0 [...] rt.cpan.org> <rt-4.0.18-23833-1439809707-1169.80162-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-13816-1440938423-1132.80162-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: 327
Download (untitled) / with headers
text/plain 327b
I have looked further into this, and it seems like changes need to be made in the new() methods of Math::BigInt, Math::BigFloat, Math::BigRat, and Math::BigInt::Lite to get the same semantics as core Perl. I'm not yet sure whether the best solution is to use a config() option or to introduce a subclass for each of the above.
MIME-Version: 1.0
In-Reply-To: <rt-4.0.18-13816-1440938423-1132.80162-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <RT-Ticket-80162 [...] rt.cpan.org> <rt-4.0.18-18526-1383248250-950.80162-6-0 [...] rt.cpan.org> <c968d4cdd4e2bd1f031dbceff01680e1.squirrel [...] webmail.think-electric.com> <rt-4.0.18-23862-1383457010-283.80162-0-0 [...] rt.cpan.org> <rt-4.0.18-23833-1439809707-1169.80162-0-0 [...] rt.cpan.org> <rt-4.0.18-13816-1440938423-1132.80162-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-17370-1443011111-119.80162-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: 194
Download (untitled) / with headers
text/plain 194b
From what I can tell, this was fixed in Math-BigInt-1.9995. If you are able to reproduce this bug, please let me know which version of the distributions Math-BigInt and bignum that are affected.
MIME-Version: 1.0
X-Spam-Status: No, score=-6.599 tagged_above=-99.9 required=10 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, FROM_OUR_RT=-4, RCVD_IN_DNSWL_LOW=-0.7] autolearn=ham
In-Reply-To: <rt-4.0.18-17370-1443011112-57.80162-6-0 [...] rt.cpan.org>
X-Spam-Flag: NO
X-RT-Interface: API
References: <RT-Ticket-80162 [...] rt.cpan.org> <rt-4.0.18-18526-1383248250-950.80162-6-0 [...] rt.cpan.org> <c968d4cdd4e2bd1f031dbceff01680e1.squirrel [...] webmail.think-electric.com> <rt-4.0.18-23862-1383457010-283.80162-6-0 [...] rt.cpan.org> <rt-4.0.18-23833-1439809707-1169.80162-6-0 [...] rt.cpan.org> <rt-4.0.18-13816-1440938423-1132.80162-6-0 [...] rt.cpan.org> <rt-4.0.18-17370-1443011112-57.80162-6-0 [...] rt.cpan.org>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
X-Received: by 10.31.49.67 with SMTP id x64mr23353714vkx.133.1443025606801; Wed, 23 Sep 2015 09:26:46 -0700 (PDT)
Message-ID: <CA+-AwzAneV_=jCOPSDQmvpcTKekxwsh+ZYrgqDE4JwVF313xyw [...] mail.gmail.com>
content-type: text/plain; charset="utf-8"
X-RT-Original-Encoding: utf-8
X-Spam-Score: -6.599
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 E05202401D6 for <cpan-bug+Math-BigInt [...] hipster.bestpractical.com>; Wed, 23 Sep 2015 12:26:55 -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 05y7vJudtM11 for <cpan-bug+Math-BigInt [...] hipster.bestpractical.com>; Wed, 23 Sep 2015 12:26:54 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id 52B56240029 for <bug-Math-BigInt [...] rt.cpan.org>; Wed, 23 Sep 2015 12:26:54 -0400 (EDT)
Received: (qmail 29118 invoked by alias); 23 Sep 2015 16:26:52 -0000
Received: from mail-vk0-f44.google.com (HELO mail-vk0-f44.google.com) (209.85.213.44) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Wed, 23 Sep 2015 09:26:50 -0700
Received: by vkao3 with SMTP id o3so30950965vka.2 for <bug-Math-BigInt [...] rt.cpan.org>; Wed, 23 Sep 2015 09:26:47 -0700 (PDT)
Received: by 10.103.90.204 with HTTP; Wed, 23 Sep 2015 09:26:46 -0700 (PDT)
Delivered-To: cpan-bug+Math-BigInt [...] hipster.bestpractical.com
Subject: Re: [rt.cpan.org #80162] Can no longer subtract an undefined value.
Return-Path: <turtle.schmiechen [...] gmail.com>
Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:content-type; bh=TZBYrLzhC8vVvhK+xPU4YGVmBInbuY1qjsZHy/DT/lo=; b=OF1yGOF7FnU2ww4lYl+ucnLkwd6gEHMaj5xRTTSbyJwSbcmPlEgEOHOSpnNfcZizAQ EN05h3YD8LHw1hZ9jHtKvPI86ytD4SGSTT3bGJ5MMdMZR0m9kmq4YlHUdiGOcyQSYOwc qsO43Ar0TMk/6w/8FQmK2J3ZODWcw9HJcKzSph8fuRuVFBoOK3C3yFxyvmeJX06pOCQ6 8xXZFR5lw/17dObf0vndkETvvBt8Iydy3/Osywgm5wPZeV9z6Zc15nNBrB0o9Ziegtzf C582SFzz9JU3ejy+M04HnYq5ZbJ8JZASYmKQx2xT9DBqn9nNht9Jpmij791mcSQ4HA4q lilw==
X-Spam-Check-BY: la.mx.develooper.com
X-Original-To: cpan-bug+Math-BigInt [...] hipster.bestpractical.com
X-RT-Mail-Extension: math-bigint
X-Google-Sender-Auth: iTCxwh0a52p_k8fpRQC1T2l8ctA
Sender: turtle.schmiechen [...] gmail.com
Date: Wed, 23 Sep 2015 09:26:46 -0700
X-Spam-Level:
To: bug-Math-BigInt [...] rt.cpan.org
From: Stephen Schmiechen <turtle [...] think-electric.com>
RT-Message-ID: <rt-4.0.18-9188-1443025616-560.80162-0-0 [...] rt.cpan.org>
Content-Length: 406
Download (untitled) / with headers
text/plain 406b
Yes it is fixed the bug should be closed thank you! On Wed, Sep 23, 2015 at 5:25 AM, Peter John Acklam via RT <bug-Math-BigInt@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=80162 > > > From what I can tell, this was fixed in Math-BigInt-1.9995. If you are able to reproduce this bug, please let me know which version of the distributions Math-BigInt and bignum that are affected.
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-13966-1452068778-881.80162-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: 16
Fixed in v1.9995


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.