Skip Menu |
 

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

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

People
Owner: Nobody in particular
Requestors: Test [...] globis.net
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 1.9994



From Test [...] globis.net Mon Oct 11 13: 04:23 2010
MIME-Version: 1.0
X-Spam-Status: No, score=-6.12 tagged_above=-99.9 required=10 tests=[BAYES_00=-1.9, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_HI=-5, SPF_NEUTRAL=0.779] autolearn=ham
X-Spam-Flag: NO
X-Virus-Checked: Checked by ClamAV on 16.mx.develooper.com
Content-Type: multipart/alternative; boundary="------------090707000907040001030702"
Message-ID: <4CB34380.3020101 [...] globis.net>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
X-Virus-Scanned: Debian amavisd-new at globis01.globis.net
X-Spam-Score: -6.12
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id 88256240E29 for <cpan-bug+Math-BigInt [...] hipster.bestpractical.com>; Mon, 11 Oct 2010 13:04:23 -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 v5Lqkl5uJKYV for <cpan-bug+Math-BigInt [...] hipster.bestpractical.com>; Mon, 11 Oct 2010 13:04:17 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id 50F03240E15 for <bug-Math-BigInt [...] rt.cpan.org>; Mon, 11 Oct 2010 13:04:16 -0400 (EDT)
Received: (qmail 16325 invoked by uid 103); 11 Oct 2010 17:04:18 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 11 Oct 2010 17:04:18 -0000
Received: from mail.globis.net (HELO globis01.globis.net) (87.195.182.18) by 16.mx.develooper.com (qpsmtpd/0.80) with ESMTP; Mon, 11 Oct 2010 10:04:16 -0700
Received: from localhost (localhost [127.0.0.1]) by globis01.globis.net (Postfix) with ESMTP id EF5E087007F for <bug-Math-BigInt [...] rt.cpan.org>; Mon, 11 Oct 2010 19:04:11 +0200 (CEST)
Received: from globis01.globis.net ([127.0.0.1]) by localhost (mail.globis.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FlptE6VMZ1Z7 for <bug-Math-BigInt [...] rt.cpan.org>; Mon, 11 Oct 2010 19:04:01 +0200 (CEST)
Received: from Rays-iMac.local (unknown [192.168.0.3]) (Authenticated sender: Ray.Hunter [...] globis.net) by globis01.globis.net (Postfix) with ESMTPA id 65CFF87007A for <bug-Math-BigInt [...] rt.cpan.org>; Mon, 11 Oct 2010 19:04:01 +0200 (CEST)
Delivered-To: cpan-bug+Math-BigInt [...] hipster.bestpractical.com
Subject: BigInt documentation is a tad misleading for brsft
User-Agent: Postbox Express 1.0.1 (Macintosh/20100705)
Return-Path: <Test [...] globis.net>
X-RT-Mail-Extension: math-bigint
X-Original-To: cpan-bug+Math-BigInt [...] hipster.bestpractical.com
X-Spam-Check-BY: 16.mx.develooper.com
Date: Mon, 11 Oct 2010 19:04:00 +0200
X-Spam-Level:
To: bug-Math-BigInt [...] rt.cpan.org
From: Test <Test [...] globis.net>
Content-Length: 0
content-type: text/plain; charset="utf-8"; format="flowed"
Content-Transfer-Encoding: 7bit
X-RT-Original-Encoding: ISO-8859-1
Content-Length: 1519
Download (untitled) / with headers
text/plain 1.4k
Package: Math::BigInt Distribution: straight from cpan. Verison: 1.89 Thanks for the code. I'm grateful. Honest. But I did encounter a wee disappointment. The html documentation seems to state: brsft() <http://search.cpan.org/%7Eflora/Math-BigInt-1.96/lib/Math/BigInt.pm#___top> $x->brsft($y,$n); Shifts $x right by $y in base $n. Default is base 2, used are usually 10 and 2, but others work, too. But looking in the pod documentation in the distrution package: line 3183 of the synopsis states $x->brsft($y); # right shift in base 2 # returns (quo,rem) or quo if in scalar context However, the real working code does not seem to be at all context sensitive i.e. it never returns rem (comes back as undef) I find this is a bit of a shame for simple situations where you want to take the first and second nibble e.g. like stripping out the first and second 64 bits of an IPv6 address to be stored in a MySQL database which can't handle 128 bits in one integer. I ended up using: sub IP_to_db { # make sure the input really is a bigint my $bint = Math::BigInt->new(shift); my $top_nibble=Math::BigInt->new(1); $top_nibble->blsft(64); # left shift 64 bits my $nibble_a; my $nibble_b; ($nibble_a,$nibble_b)= $bint->bdiv($top_nibble); # split into 2*64 bits for MySQL which is probably a lot less efficient than my $nibble_a; my $nibble_b; ($nibble_a,$nibble_b)= $bint->brsft(64); (depending on the internal representation of course) redards,
content-type: text/html; charset="utf-8"
Content-Transfer-Encoding: 7bit
X-RT-Original-Encoding: ISO-8859-1
Content-Length: 2139
MIME-Version: 1.0
In-Reply-To: <4CB34380.3020101 [...] globis.net>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
References: <4CB34380.3020101 [...] globis.net>
Content-Type: multipart/mixed; boundary="----------=_1286865690-2362-2"
Message-ID: <rt-3.8.HEAD-2362-1286865690-1073.62052-0-0 [...] rt.cpan.org>
X-RT-Original-Encoding: utf-8
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: 239
Download (untitled) / with headers
text/plain 239b
This is clearly a bug in the documentation. There is nothing in the code for brsft() and blsft() indicating that these methods were ever supposed to return both the quotient and the remainder. I have attached a patch that corrects the POD.
MIME-Version: 1.0
Subject: Math-BigInt-id-62052.txt
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Type: text/plain; charset="utf-8"; name="Math-BigInt-id-62052.txt"
Content-Disposition: inline; filename="Math-BigInt-id-62052.txt"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 602
--- lib/Math/BigInt.pm.orig 2010-10-12 08:23:49.218113600 +0200 +++ lib/Math/BigInt.pm 2010-10-12 08:44:19.507182400 +0200 @@ -3180,10 +3180,8 @@ $x->bpow($y); # power of arguments (x ** y) $x->blsft($y); # left shift in base 2 $x->brsft($y); # right shift in base 2 - # returns (quo,rem) or quo if in scalar context $x->blsft($y,$n); # left shift by $y places in base $n $x->brsft($y,$n); # right shift by $y places in base $n - # returns (quo,rem) or quo if in scalar context $x->band($y); # bitwise and $x->bior($y); # bitwise inclusive or
From Test [...] globis.net Tue Oct 12 03: 24:45 2010
MIME-Version: 1.0
X-Spam-Status: No, score=-6.12 tagged_above=-99.9 required=10 tests=[AWL=0.001, BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, SPF_NEUTRAL=0.779] autolearn=ham
In-Reply-To: <rt-3.8.HEAD-2362-1286865690-1983.62052-6-0 [...] rt.cpan.org>
X-Spam-Flag: NO
References: <RT-Ticket-62052 [...] rt.cpan.org> <4CB34380.3020101 [...] globis.net> <rt-3.8.HEAD-2362-1286865690-1983.62052-6-0 [...] rt.cpan.org>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
X-Virus-Scanned: Debian amavisd-new at globis01.globis.net
Message-ID: <4CB40D2E.7080101 [...] globis.net>
Content-Type: text/plain; charset=UTF-8; format=flowed
X-RT-Original-Encoding: utf-8
X-Spam-Score: -6.12
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id AD286240E2C for <cpan-bug+Math-BigInt [...] hipster.bestpractical.com>; Tue, 12 Oct 2010 03:24:45 -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 wac1AAmBgd6T for <cpan-bug+Math-BigInt [...] hipster.bestpractical.com>; Tue, 12 Oct 2010 03:24:43 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id A0A3B240E2B for <bug-Math-BigInt [...] rt.cpan.org>; Tue, 12 Oct 2010 03:24:43 -0400 (EDT)
Received: (qmail 22053 invoked by uid 103); 12 Oct 2010 07:24:45 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 12 Oct 2010 07:24:45 -0000
Received: from mail.globis.net (HELO globis01.globis.net) (87.195.182.18) by 16.mx.develooper.com (qpsmtpd/0.80) with ESMTP; Tue, 12 Oct 2010 00:24:41 -0700
Received: from localhost (localhost [127.0.0.1]) by globis01.globis.net (Postfix) with ESMTP id 8E533870080 for <bug-Math-BigInt [...] rt.cpan.org>; Tue, 12 Oct 2010 09:24:37 +0200 (CEST)
Received: from globis01.globis.net ([127.0.0.1]) by localhost (mail.globis.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id okoUKb2LUhCx for <bug-Math-BigInt [...] rt.cpan.org>; Tue, 12 Oct 2010 09:24:31 +0200 (CEST)
Received: from Rays-iMac.local (unknown [192.168.0.3]) (Authenticated sender: Ray.Hunter [...] globis.net) by globis01.globis.net (Postfix) with ESMTPA id 46EF287007F for <bug-Math-BigInt [...] rt.cpan.org>; Tue, 12 Oct 2010 09:24:31 +0200 (CEST)
Delivered-To: cpan-bug+Math-BigInt [...] hipster.bestpractical.com
User-Agent: Postbox Express 1.0.1 (Macintosh/20100705)
Subject: Re: [rt.cpan.org #62052] BigInt documentation is a tad misleading for brsft
Return-Path: <Test [...] globis.net>
X-Spam-Check-BY: 16.mx.develooper.com
X-Original-To: cpan-bug+Math-BigInt [...] hipster.bestpractical.com
X-RT-Mail-Extension: math-bigint
Date: Tue, 12 Oct 2010 09:24:30 +0200
X-Spam-Level:
To: bug-Math-BigInt [...] rt.cpan.org
Content-Transfer-Encoding: 7bit
From: Test <Test [...] globis.net>
RT-Message-ID: <rt-3.8.HEAD-2356-1286868289-463.62052-0-0 [...] rt.cpan.org>
Content-Length: 1284
Download (untitled) / with headers
text/plain 1.2k
Peter John Acklam via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=62052> > > This is clearly a bug in the documentation. There is nothing in the code > for brsft() and blsft() indicating that these methods were ever supposed > to return both the quotient and the remainder. I have attached a patch > that corrects the POD. >
Fair enough. I accept that explanation and shall continue to use my alternative code. Just FYI: in the rather ancient World of integer arithmetic and 8 bit microprocessors, it was common when performing operations like logical shift right or arithmetic shift left to preserve the bits that "fell off the end" during the shift so you could use them in another result see e.g. 6502 LSR & ASL opcodes where the additional bit drops into the "carry bit" which you can then shift into another register, thus extending maths beyond your original 8 bits. That exactly corresponds to what I was trying to do (except for 64 bits) although I accept that the general point of the bigint lib is that normally you shouldn't have to perform such primitive operations. Shame MySQL still has the hard 64 bit limit on integers. Maybe I/someone should be adding this to the Net::IP library, as I suspect it will be quite a common requirement.
MIME-Version: 1.0
In-Reply-To: <rt-3.8.HEAD-2356-1286868289-463.62052-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
References: <RT-Ticket-62052 [...] rt.cpan.org> <4CB34380.3020101 [...] globis.net> <rt-3.8.HEAD-2362-1286865690-1983.62052-6-0 [...] rt.cpan.org> <4CB40D2E.7080101 [...] globis.net> <rt-3.8.HEAD-2356-1286868289-463.62052-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-2360-1286877826-1877.62052-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 986
Download (untitled) / with headers
text/plain 986b
On Tue Oct 12 03:24:49 2010, Test@globis.net wrote: Show quoted text
> Fair enough. I accept that explanation and shall continue to use my > alternative code. (...)
Thanks for the information. It turns out that both the code and the documentation for Math::BigFloat suggest that the behaviour you want corresponds to that of Math::BigFloat, that the return values of brsft() in list context is indeed the quotient and the remainder. Firstly, it seems inconsistent to me that Math::BigInt and Math::BigFloat behaves differently. I think either both of them or none of them ought to return the quotient and remainder in list context. Secondly, it seems that the behaviour of Math::BigFloat doesn't match the documentation: $ perl -I. -MMath::BigFloat -wle '$x = Math::BigFloat -> new(2345); ($q, $r) = $x -> brsft(2, 10); print for $x, $q, $r' 23.45 23.45 45 While the input is shifted two places, the output in $q is clearly not the quotient. Now, if only Math-BigInt had an active maintainer ...
From rafl [...] debian.org Tue Oct 12 06: 22:03 2010
MIME-Version: 1.0
X-Spam-Status: No, score=-6.381 tagged_above=-99.9 required=10 tests=[AWL=0.519, BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5] autolearn=ham
In-Reply-To: <rt-3.8.HEAD-2360-1286877827-1265.62052-5-0 [...] rt.cpan.org> (Peter John Acklam via's message of "Tue, 12 Oct 2010 06:03:47 -0400")
X-Spam_score: -3.9
X-Spam-Flag: NO
References: <RT-Ticket-62052 [...] rt.cpan.org> <4CB34380.3020101 [...] globis.net> <rt-3.8.HEAD-2362-1286865690-1983.62052-6-0 [...] rt.cpan.org> <4CB40D2E.7080101 [...] globis.net> <rt-3.8.HEAD-2356-1286868289-463.62052-5-0 [...] rt.cpan.org> <rt-3.8.HEAD-2360-1286877827-1265.62052-5-0 [...] rt.cpan.org>
X-Virus-Checked: Checked by ClamAV on 16.mx.develooper.com
X-Spam_bar: ---
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
Message-ID: <87eibvww3a.fsf [...] tardis.home.perldition.org>
Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature"
X-Spam-Score: -6.381
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id F2A8A240E2F for <cpan-bug+Math-BigInt [...] hipster.bestpractical.com>; Tue, 12 Oct 2010 06:22:02 -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 N2iBaDKlhbYM for <cpan-bug+Math-BigInt [...] hipster.bestpractical.com>; Tue, 12 Oct 2010 06:22:00 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id 7A718240E2C for <bug-Math-BigInt [...] rt.cpan.org>; Tue, 12 Oct 2010 06:22:00 -0400 (EDT)
Received: (qmail 12610 invoked by uid 103); 12 Oct 2010 10:22:02 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 12 Oct 2010 10:22:02 -0000
Received: from kief.perldition.org (HELO kief.perldition.org) (78.47.20.161) by 16.mx.develooper.com (qpsmtpd/0.80) with ESMTP; Tue, 12 Oct 2010 03:22:00 -0700
Received: from p4fd75ec6.dip.t-dialin.net ([79.215.94.198] helo=tardis.home.perldition.org) by kief.perldition.org with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from <rafl [...] debian.org>) id 1P5bzX-0003Jy-SA for bug-Math-BigInt [...] rt.cpan.org; Tue, 12 Oct 2010 12:21:56 +0200
Received: from rafl by tardis.home.perldition.org with local (Exim 4.72) (envelope-from <rafl [...] debian.org>) id 1P5byf-0001Qh-Dk for bug-Math-BigInt [...] rt.cpan.org; Tue, 12 Oct 2010 12:21:01 +0200
Delivered-To: cpan-bug+Math-BigInt [...] hipster.bestpractical.com
X-Spam_score_int: -38
Subject: Re: [rt.cpan.org #62052] BigInt documentation is a tad misleading for brsft
User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.2 (gnu/linux)
Return-Path: <rafl [...] debian.org>
X-Spam-Check-BY: 16.mx.develooper.com
X-Original-To: cpan-bug+Math-BigInt [...] hipster.bestpractical.com
X-RT-Mail-Extension: math-bigint
Date: Tue, 12 Oct 2010 12:20:57 +0200
X-Spam-Level:
X-Spam_report: Spam detection software, running on the system "kief.perldition.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: "Peter John Acklam via RT" <bug-Math-BigInt [...] rt.cpan.org> writes: > Now, if only Math-BigInt had an active maintainer ... FWIW, I'm right here, listening to the discussion about this and the various other tickets, and the last release of Math-BigInt happened 2 weeks ago. [...] Content analysis details: (-3.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.8 ALL_TRUSTED Passed through trusted hosts only via SMTP -2.6 BAYES_00 BODY: Bayesian spam probability is 0 to 1% [score: 0.0000] 0.5 AWL AWL: From: address is in the auto white-list
To: bug-Math-BigInt [...] rt.cpan.org
From: Florian Ragwitz <rafl [...] debian.org>
RT-Message-ID: <rt-3.8.HEAD-2357-1286878926-1971.62052-0-0 [...] rt.cpan.org>
Content-Length: 0
Content-Type: text/plain; charset="utf-8"
X-RT-Original-Encoding: utf-8
Content-Length: 748
Download (untitled) / with headers
text/plain 748b
"Peter John Acklam via RT" <bug-Math-BigInt@rt.cpan.org> writes: Show quoted text
> Now, if only Math-BigInt had an active maintainer ...
FWIW, I'm right here, listening to the discussion about this and the various other tickets, and the last release of Math-BigInt happened 2 weeks ago. While I don't have the resources to attend to each issue immediately, I do try to work on the various Math-Big*/bignum RT queues, as you might've noticed from $many to 1 open issue within the last few weeks. I'm sorry if that isn't as active as you might wish, but I am trying my best under the given constraints. Any help, especially those in the form of patches, but also simply reporting issues, or following the RT queue and discussing issues, is *hugely* appreciated.
Content-Type: application/pgp-signature
Content-Length: 197
Download (untitled)
application/pgp-signature 197b

Message body not shown because it is not plain text.

MIME-Version: 1.0
In-Reply-To: <rt-3.8.HEAD-2357-1286878926-1971.62052-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
References: <RT-Ticket-62052 [...] rt.cpan.org> <4CB34380.3020101 [...] globis.net> <rt-3.8.HEAD-2362-1286865690-1983.62052-6-0 [...] rt.cpan.org> <4CB40D2E.7080101 [...] globis.net> <rt-3.8.HEAD-2356-1286868289-463.62052-5-0 [...] rt.cpan.org> <rt-3.8.HEAD-2360-1286877827-1265.62052-5-0 [...] rt.cpan.org> <87eibvww3a.fsf [...] tardis.home.perldition.org> <rt-3.8.HEAD-2357-1286878926-1971.62052-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-2359-1286879478-202.62052-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 484
Download (untitled) / with headers
text/plain 484b
On Tue Oct 12 06:22:06 2010, FLORA wrote: Show quoted text
> "Peter John Acklam via RT" <bug-Math-BigInt@rt.cpan.org> writes: >
> > Now, if only Math-BigInt had an active maintainer ...
> > FWIW, I'm right here (...)
I'm very sorry, I thought TELS was the only maintainer. I contacted him, but I got a reply telling me he had no time to maintain this distribution. I see now that there are several other maintainers. And I fully understand that you can't reply immediately. Again, sorry about that.
MIME-Version: 1.0
In-Reply-To: <rt-3.8.HEAD-2360-1286877826-1877.62052-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
References: <RT-Ticket-62052 [...] rt.cpan.org> <4CB34380.3020101 [...] globis.net> <rt-3.8.HEAD-2362-1286865690-1983.62052-6-0 [...] rt.cpan.org> <4CB40D2E.7080101 [...] globis.net> <rt-3.8.HEAD-2356-1286868289-463.62052-0-0 [...] rt.cpan.org> <rt-3.8.HEAD-2360-1286877826-1877.62052-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-2363-1286880033-14.62052-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 1030
On Tue Oct 12 06:03:46 2010, pjacklam wrote: Show quoted text
> Secondly, it seems that the behaviour of Math::BigFloat doesn't match > the documentation: > > $ perl -I. -MMath::BigFloat -wle '$x = Math::BigFloat -> new(2345); ($q, > $r) = $x -> brsft(2, 10); print for $x, $q, $r' > 23.45 > 23.45 > 45 > > While the input is shifted two places, the output in $q is clearly not > the quotient.
After re-thinking this, $q = 23.45 is of course the quotient, assuming that you are dividing 2345 by 10**2. However, when one is talking about quotient and remainder ($q and $r, say) after dividing a numerator by a denominator ($n and $d, say), it usually means that one gets a $q and $r satisfying $n = $q * $d + $r. That is not the case with Math::BigFloat's brsft(). So, while the behaviour of Math::BigFloat might not be wrong, I think it is a little - what shall I say? - unexpected. I think the most useful and intuitive would be if Math::BigFloat -> new(2345) -> brsft(2, 10) returned 23.45 in scalar context, and (23, 45) in list context.
From rafl [...] debian.org Tue Oct 12 06: 42:12 2010
CC: undisclosed-recipients:;
MIME-Version: 1.0
X-Spam-Status: No, score=-6.397 tagged_above=-99.9 required=10 tests=[AWL=0.503, BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5] autolearn=ham
In-Reply-To: <rt-3.8.HEAD-2359-1286879478-1507.62052-5-0 [...] rt.cpan.org> (Peter John Acklam via's message of "Tue, 12 Oct 2010 06:31:19 -0400")
X-Spam_score: -3.9
X-Spam-Flag: NO
References: <RT-Ticket-62052 [...] rt.cpan.org> <4CB34380.3020101 [...] globis.net> <rt-3.8.HEAD-2362-1286865690-1983.62052-6-0 [...] rt.cpan.org> <4CB40D2E.7080101 [...] globis.net> <rt-3.8.HEAD-2356-1286868289-463.62052-5-0 [...] rt.cpan.org> <rt-3.8.HEAD-2360-1286877827-1265.62052-5-0 [...] rt.cpan.org> <87eibvww3a.fsf [...] tardis.home.perldition.org> <rt-3.8.HEAD-2357-1286878926-1971.62052-5-0 [...] rt.cpan.org> <rt-3.8.HEAD-2359-1286879478-1507.62052-5-0 [...] rt.cpan.org>
X-Virus-Checked: Checked by ClamAV on 16.mx.develooper.com
X-Spam_bar: ---
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
Message-ID: <8762x7wv5n.fsf [...] tardis.home.perldition.org>
Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature"
X-Spam-Score: -6.397
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id E75B7240E32 for <cpan-bug+Math-BigInt [...] hipster.bestpractical.com>; Tue, 12 Oct 2010 06:42:11 -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 Je-Qxxm8EgUZ for <cpan-bug+Math-BigInt [...] hipster.bestpractical.com>; Tue, 12 Oct 2010 06:42:09 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id EAAEC240E31 for <bug-Math-BigInt [...] rt.cpan.org>; Tue, 12 Oct 2010 06:42:08 -0400 (EDT)
Received: (qmail 15290 invoked by uid 103); 12 Oct 2010 10:42:11 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 12 Oct 2010 10:42:11 -0000
Received: from kief.perldition.org (HELO kief.perldition.org) (78.47.20.161) by 16.mx.develooper.com (qpsmtpd/0.80) with ESMTP; Tue, 12 Oct 2010 03:42:09 -0700
Received: from p4fd75ec6.dip.t-dialin.net ([79.215.94.198] helo=tardis.home.perldition.org) by kief.perldition.org with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from <rafl [...] debian.org>) id 1P5cJ3-0003MY-5A for bug-Math-BigInt [...] rt.cpan.org; Tue, 12 Oct 2010 12:42:06 +0200
Received: from rafl by tardis.home.perldition.org with local (Exim 4.72) (envelope-from <rafl [...] debian.org>) id 1P5cIB-0001Tl-GT for bug-Math-BigInt [...] rt.cpan.org; Tue, 12 Oct 2010 12:41:11 +0200
Delivered-To: cpan-bug+Math-BigInt [...] hipster.bestpractical.com
X-Spam_score_int: -38
Subject: Re: [rt.cpan.org #62052] BigInt documentation is a tad misleading for brsft
User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.2 (gnu/linux)
Return-Path: <rafl [...] debian.org>
X-Spam-Check-BY: 16.mx.develooper.com
X-Original-To: cpan-bug+Math-BigInt [...] hipster.bestpractical.com
X-RT-Mail-Extension: math-bigint
Date: Tue, 12 Oct 2010 12:41:08 +0200
X-Spam-Level:
X-Spam_report: Spam detection software, running on the system "kief.perldition.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: "Peter John Acklam via RT" <bug-Math-BigInt [...] rt.cpan.org> writes: > On Tue Oct 12 06:22:06 2010, FLORA wrote: >> "Peter John Acklam via RT" <bug-Math-BigInt [...] rt.cpan.org> writes: >> >> > Now, if only Math-BigInt had an active maintainer ... >> >> FWIW, I'm right here (...) > > I'm very sorry, I thought TELS was the only maintainer. I contacted > him, but I got a reply telling me he had no time to maintain this > distribution. I see now that there are several other maintainers. And > I fully understand that you can't reply immediately. Again, sorry > about that. [...] Content analysis details: (-3.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.8 ALL_TRUSTED Passed through trusted hosts only via SMTP -2.6 BAYES_00 BODY: Bayesian spam probability is 0 to 1% [score: 0.0000] 0.5 AWL AWL: From: address is in the auto white-list
To: bug-Math-BigInt [...] rt.cpan.org
From: Florian Ragwitz <rafl [...] debian.org>
RT-Message-ID: <rt-3.8.HEAD-2356-1286880135-1834.62052-0-0 [...] rt.cpan.org>
Content-Length: 0
Content-Type: text/plain; charset="utf-8"
X-RT-Original-Encoding: utf-8
Content-Length: 757
Download (untitled) / with headers
text/plain 757b
"Peter John Acklam via RT" <bug-Math-BigInt@rt.cpan.org> writes: Show quoted text
> On Tue Oct 12 06:22:06 2010, FLORA wrote:
>> "Peter John Acklam via RT" <bug-Math-BigInt@rt.cpan.org> writes: >>
>> > Now, if only Math-BigInt had an active maintainer ...
>> >> FWIW, I'm right here (...)
> > I'm very sorry, I thought TELS was the only maintainer. I contacted > him, but I got a reply telling me he had no time to maintain this > distribution. I see now that there are several other maintainers. And > I fully understand that you can't reply immediately. Again, sorry > about that.
Don't worry. I really appreciate your comments providing extra information on the various Big* tickets. This sort of thing makes going through all of a little bit this later *much* easier.
Content-Type: application/pgp-signature
Content-Length: 197
Download (untitled)
application/pgp-signature 197b

Message body not shown because it is not plain text.

From jaleto [...] gmail.com Tue Oct 12 13: 21:56 2010
MIME-Version: 1.0
X-Spam-Status: No, score=-6.45 tagged_above=-99.9 required=10 tests=[AWL=-0.340, BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_HI=-5, SPF_NEUTRAL=0.779, T_TO_NO_BRKTS_FREEMAIL=0.01] autolearn=ham
In-Reply-To: <rt-3.8.HEAD-2356-1286880135-1498.62052-5-0 [...] rt.cpan.org>
X-Spam-Flag: NO
References: <RT-Ticket-62052 [...] rt.cpan.org> <4CB34380.3020101 [...] globis.net> <rt-3.8.HEAD-2362-1286865690-1983.62052-6-0 [...] rt.cpan.org> <4CB40D2E.7080101 [...] globis.net> <rt-3.8.HEAD-2356-1286868289-463.62052-5-0 [...] rt.cpan.org> <rt-3.8.HEAD-2360-1286877827-1265.62052-5-0 [...] rt.cpan.org> <87eibvww3a.fsf [...] tardis.home.perldition.org> <rt-3.8.HEAD-2357-1286878926-1971.62052-5-0 [...] rt.cpan.org> <rt-3.8.HEAD-2359-1286879478-1507.62052-5-0 [...] rt.cpan.org> <8762x7wv5n.fsf [...] tardis.home.perldition.org> <rt-3.8.HEAD-2356-1286880135-1498.62052-5-0 [...] rt.cpan.org>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
Message-ID: <AANLkTinz=ySO8bF8hT2kw-yKXF7GWxgxWpOZXAbY=8fL [...] mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
X-RT-Original-Encoding: utf-8
X-Spam-Score: -6.45
Authentication-Results: hipster.bestpractical.com (amavisd-new); dkim=pass header.i= [...] gmail.com
Authentication-Results: hipster.bestpractical.com (amavisd-new); domainkeys=pass header.sender=jaleto [...] gmail.com
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id 896D0240E43 for <cpan-bug+Math-BigInt [...] hipster.bestpractical.com>; Tue, 12 Oct 2010 13:21: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 EiN-SZPGWpgV for <cpan-bug+Math-BigInt [...] hipster.bestpractical.com>; Tue, 12 Oct 2010 13:21:50 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id 83122240E40 for <bug-Math-BigInt [...] rt.cpan.org>; Tue, 12 Oct 2010 13:21:50 -0400 (EDT)
Received: (qmail 29913 invoked by uid 103); 12 Oct 2010 17:21:53 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 12 Oct 2010 17:21:53 -0000
Received: from mail-pz0-f50.google.com (HELO mail-pz0-f50.google.com) (209.85.210.50) by 16.mx.develooper.com (qpsmtpd/0.80) with ESMTP; Tue, 12 Oct 2010 10:21:51 -0700
Received: by pzk37 with SMTP id 37so204135pzk.9 for <bug-Math-BigInt [...] rt.cpan.org>; Tue, 12 Oct 2010 10:21:48 -0700 (PDT)
Received: by 10.142.12.11 with SMTP id 11mr4456135wfl.321.1286904108285; Tue, 12 Oct 2010 10:21:48 -0700 (PDT)
Received: by 10.220.180.200 with HTTP; Tue, 12 Oct 2010 10:21:31 -0700 (PDT)
Delivered-To: cpan-bug+Math-BigInt [...] hipster.bestpractical.com
Subject: Re: [rt.cpan.org #62052] BigInt documentation is a tad misleading for brsft
Domainkey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type; b=WDw0upJQcgbkhekWJYC1S1bKaeqKKoP8hBU/DijJusMurooCD49DRdMR9PIc5qgh3U v3CTL6LyCVDCRw1MPSb6HgUAYWaGBy2KQ4CW5CXYrmdpZcmV96vIElvsl+FtXi9miqh9 q0w/n1nvfBZiJxvOpNbfzJnwGJaj2iLpVrh2c=
Return-Path: <jaleto [...] gmail.com>
Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:sender:received :in-reply-to:references:from:date:x-google-sender-auth:message-id :subject:to:content-type; bh=cnm5eF6daCKxYCBAm0h4eL/SyZzBkerQzdC/vzfQXeg=; b=IQYy3swap0ig9TyVWRv7GBAvOM+2G3Oq2WezkW1DOSSPIbnU+PGrdxsoj2OPgUrZBY RTctFGzJmulYz5CEXrFh2lFUpW1NHVlrzhRDcDhSrrdu1DP48EeSh6JAI4jfvnL9ddMw XHNb4dA/fI4Stji/s/djluFYUE2ECLg3Qrra8=
X-Spam-Check-BY: 16.mx.develooper.com
X-Original-To: cpan-bug+Math-BigInt [...] hipster.bestpractical.com
X-RT-Mail-Extension: math-bigint
X-Google-Sender-Auth: Z1lc495UoKHH6fPaDcYpFnmfpes
Sender: jaleto [...] gmail.com
Date: Tue, 12 Oct 2010 10:21:31 -0700
X-Spam-Level:
To: bug-Math-BigInt [...] rt.cpan.org
From: Jonathan Leto <jonathan [...] leto.net>
RT-Message-ID: <rt-3.8.HEAD-2357-1286904120-1406.62052-0-0 [...] rt.cpan.org>
Content-Length: 502
Download (untitled) / with headers
text/plain 502b
Howdy, Show quoted text
>> On Tue Oct 12 06:22:06 2010, FLORA wrote:
>>> "Peter John Acklam via RT" <bug-Math-BigInt@rt.cpan.org> writes: >>>
>>> > Now, if only Math-BigInt had an active maintainer ...
>>> >>> FWIW, I'm right here (...)
I am here too, for some definition of "active." I tried to take over for TELS, but then realized I don't have as much time as I would like to work on it. I commend Florian for actually making things happen lately. Duke -- Jonathan "Duke" Leto jonathan@leto.net http://leto.net
MIME-Version: 1.0
In-Reply-To: <4CB34380.3020101 [...] globis.net>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
References: <4CB34380.3020101 [...] globis.net>
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-25792-1341856959-309.62052-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
RT-Send-CC: jonathan [...] leto.net, rafl [...] debian.org
Content-Length: 172
Download (untitled) / with headers
text/plain 172b
This appears to still be an issue. Show quoted text
>perl -I. -MMath::BigFloat -wle "$x = Math::BigFloat -> new(2345); ($q,
$r) = $x -> brsft(2, 10); print for $x, $q, $r" 23.45 23.45 45
MIME-Version: 1.0
In-Reply-To: <rt-3.8.HEAD-25792-1341856959-309.62052-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <4CB34380.3020101 [...] globis.net> <rt-3.8.HEAD-25792-1341856959-309.62052-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-4101-1397586496-483.62052-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: 722
Download (untitled) / with headers
text/plain 722b
The subject is inaccurate. The documentation for brsft() in both BigInt and BigFloat are fine. The bug is in bdiv(): The expression ($q, $r) = Math::BigFloat -> new($a) -> brsft($b, $c)' is computed as ($q, $r) = Math::BigFloat -> new($a) -> bdiv($b -> bpow($c))' so the example above, $ perl -Idist/Math-BigInt/lib/ -MMath::BigFloat -wle '$x = Math::BigFloat -> new(2345); ($q, $r) = $x -> brsft(2, 10); print for $x, $q, $r' 23.45 23.45 45 can be simplified into $ perl -Idist/Math-BigInt/lib/ -MMath::BigFloat -wle '($q, $r) = Math::BigFloat -> new(2345) -> bdiv(100); print for $q, $r' 23.45 45 which illustrates the same problem. In list context, this should give 23 and 45. So the bug is actually in bdiv().
MIME-Version: 1.0
In-Reply-To: <rt-4.0.18-4101-1397586496-483.62052-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <4CB34380.3020101 [...] globis.net> <rt-3.8.HEAD-25792-1341856959-309.62052-0-0 [...] rt.cpan.org> <rt-4.0.18-4101-1397586496-483.62052-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-25217-1397596430-580.62052-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: 71
MIME-Version: 1.0
In-Reply-To: <4CB34380.3020101 [...] globis.net>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <4CB34380.3020101 [...] globis.net>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-733-1459794601-1929.62052-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: 24
Fixed in version 1.9994.


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.