develooper Front page | perl.perl5.porters | Postings from February 2011

[perl #84982] [PATCH] Update Math::BigInt::FastCalc to CPAN version 0.25

Thread Next
From:
perlbug-followup
Date:
February 27, 2011 02:18
Subject:
[perl #84982] [PATCH] Update Math::BigInt::FastCalc to CPAN version 0.25
Message ID:
rt-3.6.HEAD-28241-1298763402-138.84982-75-0@perl.org
# New Ticket Created by  (Peter J. Acklam) 
# Please include the string:  [perl #84982]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=84982 >


Remove _new() from XS code and use _new() in Math::BigInt::Calc
instead. The XS _new() doesn't handle integers that are too large to
be represented exactly as floating point numbers, but small enough
to be represented as 64 bit integers. E.g., even with 64 bit integer
support, applying _num() to 18446744073709551615 (= 2**64-1) gives
1.84467440737096e+19, not 18446744073709551615. The XS _new() also
returns nan, not inf, when it overflows. This closes RT #63335 and
RT #49569.
---
 dist/Math-BigInt-FastCalc/FastCalc.xs              |   37 --------------------
 .../lib/Math/BigInt/FastCalc.pm                    |   11 +++---
 2 files changed, 6 insertions(+), 42 deletions(-)

diff --git a/dist/Math-BigInt-FastCalc/FastCalc.xs b/dist/Math-BigInt-FastCalc/FastCalc.xs
index 33947a8..caf438e 100644
--- a/dist/Math-BigInt-FastCalc/FastCalc.xs
+++ b/dist/Math-BigInt-FastCalc/FastCalc.xs
@@ -256,43 +256,6 @@ _inc(class,x)
     XSRETURN(1);			/* return x */
 
 ##############################################################################
-# Make a number (scalar int/float) from a BigInt object
-
-void
-_num(class,x)
-  SV*	x
-  INIT:
-    AV*	a;
-    NV	fac;
-    SV*	temp;
-    NV	num;
-    I32	elems;
-    I32	index;
-    NV	BASE;
-
-  CODE:
-    a = (AV*)SvRV(x);			/* ref to aray, don't check ref */
-    elems = av_len(a);			/* number of elems in array */
-
-    if (elems == 0)			/* only one element? */
-      {
-      ST(0) = *av_fetch(a, 0, 0);	/* fetch first (only) element */
-      XSRETURN(1);			/* return it */
-      }
-    fac = 1.0;				/* factor */
-    index = 0;
-    num = 0.0;
-    BASE = XS_BASE;
-    while (index <= elems)
-      {
-      temp = *av_fetch(a, index, 0);	/* fetch current element */
-      num += fac * SvNV(temp);
-      fac *= BASE;
-      index++;
-      }
-    ST(0) = newSVnv(num);
-
-##############################################################################
 
 SV *
 _zero(class)
diff --git a/dist/Math-BigInt-FastCalc/lib/Math/BigInt/FastCalc.pm b/dist/Math-BigInt-FastCalc/lib/Math/BigInt/FastCalc.pm
index 650dc2b..5be37aa 100644
--- a/dist/Math-BigInt-FastCalc/lib/Math/BigInt/FastCalc.pm
+++ b/dist/Math-BigInt-FastCalc/lib/Math/BigInt/FastCalc.pm
@@ -8,18 +8,18 @@ use Math::BigInt::Calc 0.56;
 
 use vars '$VERSION';
 
-$VERSION = '0.24_02';
+$VERSION = '0.25';
 
 ##############################################################################
 # global constants, flags and accessory
 
-# announce that we are compatible with MBI v1.70 and up
-sub api_version () { 1; }
+# announce that we are compatible with MBI v1.83 and up
+sub api_version () { 2; }
 
 # use Calc to override the methods that we do not provide in XS
 
 for my $method (qw/
-    str
+    str num
     add sub mul div
     rsft lsft
     mod modpow modinv
@@ -84,7 +84,7 @@ The following functions are now implemented in FastCalc.xs:
 	_is_odd		_is_even	_is_one		_is_zero
 	_is_two		_is_ten
 	_zero		_one		_two		_ten
-	_acmp		_len		_num
+	_acmp		_len
 	_inc		_dec
 	__strip_zeros	_copy
 
@@ -100,6 +100,7 @@ in late 2000.
 Separated from BigInt and shaped API with the help of John Peacock.
 Fixed, sped-up and enhanced by Tels http://bloodgate.com 2001-2003.
 Further streamlining (api_version 1 etc.) by Tels 2004-2007.
+Bug-fixing by Peter John Acklam E<lt>pjacklam@online.noE<gt> 2010-2011.
 
 =head1 SEE ALSO
 
-- 
1.7.4


Thread Next


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