Difference between revisions of "Math::BigInt"

From HalfgeekKB
Jump to navigation Jump to search
 
Line 27: Line 27:
 
  print $b == $c ? "Same object" : "Not same object";
 
  print $b == $c ? "Same object" : "Not same object";
 
   # Same object
 
   # Same object
 +
 +
=Converting a binary string to a BigInt=
 +
 +
# Code here...
 +
 +
  
  

Revision as of 10:15, 2 April 2005

Use

Specifying lib forces a library, but if that library isn't installed, fallback is automatic.

use Math::BigInt lib => 'GMP';

In-place Modification

Modification is in-place, regardless of context. A new object is not created for a result.

use Math::BigInt;

# Void context

my $a = new Math::BigInt '27';
$a->badd(3);

print "$a"; # 30

# Scalar context

my $b = new Math::BigInt '27';
my $c = $b->badd(3);

print "$b"; # 30
print "$c"; # 30
print $b == $c ? "Same object" : "Not same object";
  # Same object

Converting a binary string to a BigInt

# Code here...



See Also