This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
typo fix for bigint
[perl5.git] / dist / bignum / lib / bigint.pm
CommitLineData
126f3c5f 1package bigint;
9de9b613 2use 5.006;
126f3c5f 3
dbeba1b0 4$VERSION = '0.35';
126f3c5f 5use Exporter;
b4bc5691 6@ISA = qw( Exporter );
9663a7f5 7@EXPORT_OK = qw( PI e bpi bexp hex oct );
d98d5fa0 8@EXPORT = qw( inf NaN );
126f3c5f
JH
9
10use strict;
11use overload;
12
13##############################################################################
14
15# These are all alike, and thus faked by AUTOLOAD
16
17my @faked = qw/round_mode accuracy precision div_scale/;
18use vars qw/$VERSION $AUTOLOAD $_lite/; # _lite for testsuite
19
20sub AUTOLOAD
21 {
22 my $name = $AUTOLOAD;
23
24 $name =~ s/.*:://; # split package
25 no strict 'refs';
26 foreach my $n (@faked)
27 {
28 if ($n eq $name)
29 {
30 *{"bigint::$name"} = sub
31 {
32 my $self = shift;
33 no strict 'refs';
34 if (defined $_[0])
35 {
990fb837 36 return Math::BigInt->$name($_[0]);
126f3c5f
JH
37 }
38 return Math::BigInt->$name();
39 };
40 return &$name;
41 }
42 }
43
44 # delayed load of Carp and avoid recursion
45 require Carp;
46 Carp::croak ("Can't call bigint\-\>$name, not a valid method");
47 }
48
49sub upgrade
50 {
95a2d02c 51 $Math::BigInt::upgrade;
126f3c5f
JH
52 }
53
95a2d02c
T
54sub _binary_constant
55 {
56 # this takes a binary/hexadecimal/octal constant string and returns it
57 # as string suitable for new. Basically it converts octal to decimal, and
58 # passes every thing else unmodified back.
59 my $string = shift;
60
61 return Math::BigInt->new($string) if $string =~ /^0[bx]/;
62
63 # so it must be an octal constant
64 Math::BigInt->from_oct($string);
65 }
66
67sub _float_constant
126f3c5f
JH
68 {
69 # this takes a floating point constant string and returns it truncated to
70 # integer. For instance, '4.5' => '4', '1.234e2' => '123' etc
71 my $float = shift;
72
73 # some simple cases first
74 return $float if ($float =~ /^[+-]?[0-9]+$/); # '+123','-1','0' etc
75 return $float
76 if ($float =~ /^[+-]?[0-9]+\.?[eE]\+?[0-9]+$/); # 123e2, 123.e+2
77 return '0' if ($float =~ /^[+-]?[0]*\.[0-9]+$/); # .2, 0.2, -.1
78 if ($float =~ /^[+-]?[0-9]+\.[0-9]*$/) # 1., 1.23, -1.2 etc
79 {
80 $float =~ s/\..*//;
81 return $float;
82 }
9b924220 83 my ($mis,$miv,$mfv,$es,$ev) = Math::BigInt::_split($float);
126f3c5f
JH
84 return $float if !defined $mis; # doesn't look like a number to me
85 my $ec = int($$ev);
86 my $sign = $$mis; $sign = '' if $sign eq '+';
87 if ($$es eq '-')
88 {
89 # ignore fraction part entirely
90 if ($ec >= length($$miv)) # 123.23E-4
91 {
92 return '0';
93 }
94 return $sign . substr ($$miv,0,length($$miv)-$ec); # 1234.45E-2 = 12
95 }
96 # xE+y
97 if ($ec >= length($$mfv))
98 {
99 $ec -= length($$mfv);
100 return $sign.$$miv.$$mfv if $ec == 0; # 123.45E+2 => 12345
101 return $sign.$$miv.$$mfv.'E'.$ec; # 123.45e+3 => 12345e1
102 }
103 $mfv = substr($$mfv,0,$ec);
95a2d02c 104 $sign.$$miv.$mfv; # 123.45e+1 => 1234
126f3c5f
JH
105 }
106
4440d13a
T
107sub unimport
108 {
109 $^H{bigint} = undef; # no longer in effect
110 overload::remove_constant('binary','','float','','integer');
111 }
112
113sub in_effect
114 {
115 my $level = shift || 0;
116 my $hinthash = (caller($level))[10];
117 $hinthash->{bigint};
118 }
119
d1a15766
T
120#############################################################################
121# the following two routines are for "use bigint qw/hex oct/;":
122
9663a7f5
FC
123use constant LEXICAL => $] > 5.009004;
124
125{
126 my $proto = LEXICAL ? '_' : ';$';
127 eval '
128sub hex(' . $proto . ')' . <<'.';
d1a15766 129 {
9663a7f5 130 my $i = @_ ? $_[0] : $_;
d1a15766
T
131 $i = '0x'.$i unless $i =~ /^0x/;
132 Math::BigInt->new($i);
133 }
9663a7f5
FC
134.
135 eval '
136sub oct(' . $proto . ')' . <<'.';
d1a15766 137 {
9663a7f5
FC
138 my $i = @_ ? $_[0] : $_;
139 # oct() should never fall back to decimal
d2585a2d 140 return Math::BigInt->from_oct($i) if $i =~ s/^(?=0[0-9]|[1-9])/0/;
d1a15766
T
141 Math::BigInt->new($i);
142 }
9663a7f5
FC
143.
144}
d1a15766
T
145
146#############################################################################
147# the following two routines are for Perl 5.9.4 or later and are lexical
148
9663a7f5
FC
149my ($prev_oct, $prev_hex, $overridden);
150
151if (LEXICAL) { eval <<'.' }
152sub _hex(_)
d1a15766 153 {
9663a7f5
FC
154 my $hh = (caller 0)[10];
155 return $prev_hex ? &$prev_hex($_[0]) : CORE::hex($_[0])
156 unless $$hh{bigint}||$$hh{bignum}||$$hh{bigrat};
d1a15766
T
157 my $i = $_[0];
158 $i = '0x'.$i unless $i =~ /^0x/;
159 Math::BigInt->new($i);
160 }
161
9663a7f5 162sub _oct(_)
d1a15766 163 {
9663a7f5
FC
164 my $hh = (caller 0)[10];
165 return $prev_oct ? &$prev_oct($_[0]) : CORE::oct($_[0])
166 unless $$hh{bigint}||$$hh{bignum}||$$hh{bigrat};
d1a15766 167 my $i = $_[0];
9663a7f5 168 # oct() should never fall back to decimal
d2585a2d 169 return Math::BigInt->from_oct($i) if $i =~ s/^(?=0[0-9]|[1-9])/0/;
d1a15766
T
170 Math::BigInt->new($i);
171 }
9663a7f5
FC
172.
173
174sub _override
175 {
176 return if $overridden;
177 $prev_oct = *CORE::GLOBAL::oct{CODE};
178 $prev_hex = *CORE::GLOBAL::hex{CODE};
179 no warnings 'redefine';
180 *CORE::GLOBAL::oct = \&_oct;
181 *CORE::GLOBAL::hex = \&_hex;
182 $overridden++;
183 }
d1a15766 184
126f3c5f
JH
185sub import
186 {
187 my $self = shift;
188
4440d13a
T
189 $^H{bigint} = 1; # we are in effect
190
d1a15766 191 # for newer Perls always override hex() and oct() with a lexical version:
9663a7f5 192 if (LEXICAL)
d1a15766 193 {
9663a7f5 194 _override();
d1a15766 195 }
126f3c5f 196 # some defaults
bd49aa09 197 my $lib = ''; my $lib_kind = 'try';
126f3c5f
JH
198
199 my @import = ( ':constant' ); # drive it w/ constant
200 my @a = @_; my $l = scalar @_; my $j = 0;
201 my ($ver,$trace); # version? trace?
202 my ($a,$p); # accuracy, precision
203 for ( my $i = 0; $i < $l ; $i++,$j++ )
204 {
bd49aa09 205 if ($_[$i] =~ /^(l|lib|try|only)$/)
126f3c5f
JH
206 {
207 # this causes a different low lib to take care...
bd49aa09 208 $lib_kind = $1; $lib_kind = 'lib' if $lib_kind eq 'l';
126f3c5f 209 $lib = $_[$i+1] || '';
c4a6f826 210 my $s = 2; $s = 1 if @a-$j < 2; # avoid "can not modify non-existent..."
126f3c5f
JH
211 splice @a, $j, $s; $j -= $s; $i++;
212 }
213 elsif ($_[$i] =~ /^(a|accuracy)$/)
214 {
215 $a = $_[$i+1];
c4a6f826 216 my $s = 2; $s = 1 if @a-$j < 2; # avoid "can not modify non-existent..."
126f3c5f
JH
217 splice @a, $j, $s; $j -= $s; $i++;
218 }
219 elsif ($_[$i] =~ /^(p|precision)$/)
220 {
221 $p = $_[$i+1];
c4a6f826 222 my $s = 2; $s = 1 if @a-$j < 2; # avoid "can not modify non-existent..."
126f3c5f
JH
223 splice @a, $j, $s; $j -= $s; $i++;
224 }
225 elsif ($_[$i] =~ /^(v|version)$/)
226 {
227 $ver = 1;
228 splice @a, $j, 1; $j --;
229 }
230 elsif ($_[$i] =~ /^(t|trace)$/)
231 {
232 $trace = 1;
233 splice @a, $j, 1; $j --;
234 }
9663a7f5 235 elsif ($_[$i] !~ /^(PI|e|bpi|bexp|hex|oct)\z/)
fade31f0
T
236 {
237 die ("unknown option $_[$i]");
238 }
126f3c5f
JH
239 }
240 my $class;
241 $_lite = 0; # using M::BI::L ?
242 if ($trace)
243 {
244 require Math::BigInt::Trace; $class = 'Math::BigInt::Trace';
126f3c5f
JH
245 }
246 else
247 {
248 # see if we can find Math::BigInt::Lite
249 if (!defined $a && !defined $p) # rounding won't work to well
250 {
251 eval 'require Math::BigInt::Lite;';
252 if ($@ eq '')
253 {
254 @import = ( ); # :constant in Lite, not MBI
255 Math::BigInt::Lite->import( ':constant' );
256 $_lite= 1; # signal okay
257 }
258 }
259 require Math::BigInt if $_lite == 0; # not already loaded?
260 $class = 'Math::BigInt'; # regardless of MBIL or not
233f7bc0 261 }
bd49aa09 262 push @import, $lib_kind => $lib if $lib ne '';
126f3c5f 263 # Math::BigInt::Trace or plain Math::BigInt
233f7bc0 264 $class->import(@import);
126f3c5f
JH
265
266 bigint->accuracy($a) if defined $a;
267 bigint->precision($p) if defined $p;
268 if ($ver)
269 {
270 print "bigint\t\t\t v$VERSION\n";
271 print "Math::BigInt::Lite\t v$Math::BigInt::Lite::VERSION\n" if $_lite;
272 print "Math::BigInt\t\t v$Math::BigInt::VERSION";
273 my $config = Math::BigInt->config();
274 print " lib => $config->{lib} v$config->{lib_version}\n";
275 exit;
276 }
277 # we take care of floating point constants, since BigFloat isn't available
278 # and BigInt doesn't like them:
95a2d02c
T
279 overload::constant float => sub { Math::BigInt->new( _float_constant(shift) ); };
280 # Take care of octal/hexadecimal constants
281 overload::constant binary => sub { _binary_constant(shift) };
b4bc5691 282
4440d13a
T
283 # if another big* was already loaded:
284 my ($package) = caller();
285
286 no strict 'refs';
287 if (!defined *{"${package}::inf"})
288 {
fade31f0 289 $self->export_to_level(1,$self,@a); # export inf and NaN, e and PI
4440d13a 290 }
126f3c5f
JH
291 }
292
fade31f0
T
293sub inf () { Math::BigInt::binf(); }
294sub NaN () { Math::BigInt::bnan(); }
d98d5fa0
T
295
296sub PI () { Math::BigInt->new(3); }
297sub e () { Math::BigInt->new(2); }
298sub bpi ($) { Math::BigInt->new(3); }
299sub bexp ($$) { my $x = Math::BigInt->new($_[0]); $x->bexp($_[1]); }
b4bc5691 300
126f3c5f
JH
3011;
302
303__END__
304
305=head1 NAME
306
b4bc5691 307bigint - Transparent BigInteger support for Perl
126f3c5f
JH
308
309=head1 SYNOPSIS
310
f9156151 311 use bigint;
126f3c5f
JH
312
313 $x = 2 + 4.5,"\n"; # BigInt 6
b4bc5691
T
314 print 2 ** 512,"\n"; # really is what you think it is
315 print inf + 42,"\n"; # inf
316 print NaN * 7,"\n"; # NaN
9663a7f5 317 print hex("0x1234567890123490"),"\n"; # Perl v5.10.0 or later
126f3c5f 318
4440d13a
T
319 {
320 no bigint;
321 print 2 ** 256,"\n"; # a normal Perl scalar now
322 }
323
9663a7f5 324 # Import into current package:
d1a15766
T
325 use bigint qw/hex oct/;
326 print hex("0x1234567890123490"),"\n";
327 print oct("01234567890123490"),"\n";
328
126f3c5f
JH
329=head1 DESCRIPTION
330
45e230de
ML
331All operators (including basic math operations) except the range operator C<..>
332are overloaded. Integer constants are created as proper BigInts.
126f3c5f 333
1ad2138d
T
334Floating point constants are truncated to integer. All parts and results of
335expressions are also truncated.
336
337Unlike L<integer>, this pragma creates integer constants that are only
338limited in their size by the available memory and CPU time.
339
340=head2 use integer vs. use bigint
341
342There is one small difference between C<use integer> and C<use bigint>: the
343former will not affect assignments to variables and the return value of
344some functions. C<bigint> truncates these results to integer too:
345
346 # perl -Minteger -wle 'print 3.2'
347 3.2
348 # perl -Minteger -wle 'print 3.2 + 0'
349 3
350 # perl -Mbigint -wle 'print 3.2'
351 3
352 # perl -Mbigint -wle 'print 3.2 + 0'
353 3
354
355 # perl -Mbigint -wle 'print exp(1) + 0'
356 2
357 # perl -Mbigint -wle 'print exp(1)'
358 2
d1a15766 359 # perl -Minteger -wle 'print exp(1)'
1ad2138d 360 2.71828182845905
d1a15766 361 # perl -Minteger -wle 'print exp(1) + 0'
1ad2138d
T
362 2
363
364In practice this makes seldom a difference as B<parts and results> of
365expressions will be truncated anyway, but this can, for instance, affect the
366return value of subroutines:
367
ba048c24
FC
368 sub three_integer { use integer; return 3.2; }
369 sub three_bigint { use bigint; return 3.2; }
f703fc96 370
ba048c24 371 print three_integer(), " ", three_bigint(),"\n"; # prints "3.2 3"
126f3c5f 372
b68b7ab1 373=head2 Options
126f3c5f
JH
374
375bigint recognizes some options that can be passed while loading it via use.
376The options can (currently) be either a single letter form, or the long form.
377The following options exist:
378
379=over 2
380
381=item a or accuracy
382
383This sets the accuracy for all math operations. The argument must be greater
384than or equal to zero. See Math::BigInt's bround() function for details.
385
386 perl -Mbigint=a,2 -le 'print 12345+1'
387
c4a6f826 388Note that setting precision and accuracy at the same time is not possible.
95a2d02c 389
126f3c5f
JH
390=item p or precision
391
392This sets the precision for all math operations. The argument can be any
393integer. Negative values mean a fixed number of digits after the dot, and
394are <B>ignored</B> since all operations happen in integer space.
395A positive value rounds to this digit left from the dot. 0 or 1 mean round to
396integer and are ignore like negative values.
397
398See Math::BigInt's bfround() function for details.
399
400 perl -Mbignum=p,5 -le 'print 123456789+123'
401
c4a6f826 402Note that setting precision and accuracy at the same time is not possible.
95a2d02c 403
126f3c5f
JH
404=item t or trace
405
406This enables a trace mode and is primarily for debugging bigint or
407Math::BigInt.
408
d1a15766
T
409=item hex
410
43cde5e1 411Override the built-in hex() method with a version that can handle big
9663a7f5
FC
412integers. This overrides it by exporting it to the current package. Under
413Perl v5.10.0 and higher, this is not so necessary, as hex() is lexically
414overridden in the current scope whenever the bigint pragma is active.
d1a15766
T
415
416=item oct
417
43cde5e1 418Override the built-in oct() method with a version that can handle big
9663a7f5
FC
419integers. This overrides it by exporting it to the current package. Under
420Perl v5.10.0 and higher, this is not so necessary, as oct() is lexically
421overridden in the current scope whenever the bigint pragma is active.
d1a15766 422
bd49aa09 423=item l, lib, try or only
126f3c5f 424
bd49aa09 425Load a different math lib, see L<Math Library>.
126f3c5f 426
bd49aa09
SP
427 perl -Mbigint=lib,GMP -e 'print 2 ** 512'
428 perl -Mbigint=try,GMP -e 'print 2 ** 512'
429 perl -Mbigint=only,GMP -e 'print 2 ** 512'
126f3c5f
JH
430
431Currently there is no way to specify more than one library on the command
95a2d02c
T
432line. This means the following does not work:
433
434 perl -Mbignum=l,GMP,Pari -e 'print 2 ** 512'
435
436This will be hopefully fixed soon ;)
126f3c5f
JH
437
438=item v or version
439
440This prints out the name and version of all modules used and then exits.
441
b68b7ab1 442 perl -Mbigint=v
126f3c5f 443
95a2d02c
T
444=back
445
b68b7ab1 446=head2 Math Library
126f3c5f
JH
447
448Math with the numbers is done (by default) by a module called
449Math::BigInt::Calc. This is equivalent to saying:
450
451 use bigint lib => 'Calc';
452
453You can change this by using:
454
bd49aa09 455 use bignum lib => 'GMP';
126f3c5f
JH
456
457The following would first try to find Math::BigInt::Foo, then
458Math::BigInt::Bar, and when this also fails, revert to Math::BigInt::Calc:
459
460 use bigint lib => 'Foo,Math::BigInt::Bar';
461
bd49aa09
SP
462Using C<lib> warns if none of the specified libraries can be found and
463L<Math::BigInt> did fall back to one of the default libraries.
c4a6f826 464To suppress this warning, use C<try> instead:
bd49aa09
SP
465
466 use bignum try => 'GMP';
467
468If you want the code to die instead of falling back, use C<only> instead:
469
470 use bignum only => 'GMP';
471
126f3c5f
JH
472Please see respective module documentation for further details.
473
b68b7ab1 474=head2 Internal Format
126f3c5f
JH
475
476The numbers are stored as objects, and their internals might change at anytime,
477especially between math operations. The objects also might belong to different
478classes, like Math::BigInt, or Math::BigInt::Lite. Mixing them together, even
479with normal scalars is not extraordinary, but normal and expected.
480
481You should not depend on the internal format, all accesses must go through
990fb837 482accessor methods. E.g. looking at $x->{sign} is not a good idea since there
126f3c5f
JH
483is no guaranty that the object in question has such a hash key, nor is a hash
484underneath at all.
485
b68b7ab1 486=head2 Sign
126f3c5f 487
b68b7ab1 488The sign is either '+', '-', 'NaN', '+inf' or '-inf'.
126f3c5f
JH
489You can access it with the sign() method.
490
491A sign of 'NaN' is used to represent the result when input arguments are not
492numbers or as a result of 0/0. '+inf' and '-inf' represent plus respectively
493minus infinity. You will get '+inf' when dividing a positive number by 0, and
494'-inf' when dividing any negative number by 0.
495
a7a0833f 496=head2 Method calls
126f3c5f
JH
497
498Since all numbers are now objects, you can use all functions that are part of
499the BigInt API. You can only use the bxxx() notation, and not the fxxx()
500notation, though.
501
a7a0833f
HS
502But a warning is in order. When using the following to make a copy of a number,
503only a shallow copy will be made.
504
505 $x = 9; $y = $x;
506 $x = $y = 7;
507
508Using the copy or the original with overloaded math is okay, e.g. the
509following work:
510
511 $x = 9; $y = $x;
512 print $x + 1, " ", $y,"\n"; # prints 10 9
513
514but calling any method that modifies the number directly will result in
515B<both> the original and the copy being destroyed:
516
517 $x = 9; $y = $x;
518 print $x->badd(1), " ", $y,"\n"; # prints 10 10
519
520 $x = 9; $y = $x;
521 print $x->binc(1), " ", $y,"\n"; # prints 10 10
522
523 $x = 9; $y = $x;
524 print $x->bmul(2), " ", $y,"\n"; # prints 18 18
525
dbeba1b0 526Using methods that do not modify, but test that the contents works:
a7a0833f
HS
527
528 $x = 9; $y = $x;
529 $z = 9 if $x->is_zero(); # works fine
530
531See the documentation about the copy constructor and C<=> in overload, as
532well as the documentation in BigInt for further details.
533
534=head2 Methods
535
95a2d02c
T
536=over 2
537
538=item inf()
539
540A shortcut to return Math::BigInt->binf(). Useful because Perl does not always
541handle bareword C<inf> properly.
542
543=item NaN()
544
545A shortcut to return Math::BigInt->bnan(). Useful because Perl does not always
546handle bareword C<NaN> properly.
547
d98d5fa0
T
548=item e
549
550 # perl -Mbigint=e -wle 'print e'
551
552Returns Euler's number C<e>, aka exp(1). Note that under bigint, this is
553truncated to an integer, and hence simple '2'.
554
555=item PI
556
557 # perl -Mbigint=PI -wle 'print PI'
558
559Returns PI. Note that under bigint, this is truncated to an integer, and hence
560simple '3'.
561
562=item bexp()
563
564 bexp($power,$accuracy);
565
566Returns Euler's number C<e> raised to the appropriate power, to
567the wanted accuracy.
568
569Note that under bigint, the result is truncated to an integer.
570
571Example:
572
573 # perl -Mbigint=bexp -wle 'print bexp(1,80)'
574
575=item bpi()
576
577 bpi($accuracy);
fade31f0 578
d98d5fa0
T
579Returns PI to the wanted accuracy. Note that under bigint, this is truncated
580to an integer, and hence simple '3'.
fade31f0 581
d98d5fa0 582Example:
fade31f0 583
d98d5fa0 584 # perl -Mbigint=bpi -wle 'print bpi(80)'
fade31f0 585
95a2d02c
T
586=item upgrade()
587
588Return the class that numbers are upgraded to, is in fact returning
589C<$Math::BigInt::upgrade>.
590
4440d13a
T
591=item in_effect()
592
593 use bigint;
594
595 print "in effect\n" if bigint::in_effect; # true
596 {
597 no bigint;
598 print "in effect\n" if bigint::in_effect; # false
599 }
600
601Returns true or false if C<bigint> is in effect in the current scope.
602
603This method only works on Perl v5.9.4 or later.
604
95a2d02c
T
605=back
606
7ed767c4 607=head1 CAVEATS
d1a15766
T
608
609=over 2
610
45e230de
ML
611=item ranges
612
613Perl does not allow overloading of ranges, so you can neither safely use
614ranges with bigint endpoints, nor is the iterator variable a bigint.
615
616 use 5.010;
617 for my $i (12..13) {
618 for my $j (20..21) {
619 say $i ** $j; # produces a floating-point number,
620 # not a big integer
621 }
622 }
623
624
d1a15766
T
625=item in_effect()
626
627This method only works on Perl v5.9.4 or later.
628
629=item hex()/oct()
630
631C<bigint> overrides these routines with versions that can also handle
632big integer values. Under Perl prior to version v5.9.4, however, this
633will not happen unless you specifically ask for it with the two
634import tags "hex" and "oct" - and then it will be global and cannot be
635disabled inside a scope with "no bigint":
636
637 use bigint qw/hex oct/;
638
639 print hex("0x1234567890123456");
640 {
641 no bigint;
642 print hex("0x1234567890123456");
643 }
644
645The second call to hex() will warn about a non-portable constant.
646
647Compare this to:
648
649 use bigint;
650
651 # will warn only under Perl older than v5.9.4
652 print hex("0x1234567890123456");
653
654=back
655
126f3c5f
JH
656=head1 MODULES USED
657
658C<bigint> is just a thin wrapper around various modules of the Math::BigInt
659family. Think of it as the head of the family, who runs the shop, and orders
660the others to do the work.
661
662The following modules are currently used by bigint:
663
664 Math::BigInt::Lite (for speed, and only if it is loadable)
665 Math::BigInt
666
667=head1 EXAMPLES
668
669Some cool command line examples to impress the Python crowd ;) You might want
670to compare them to the results under -Mbignum or -Mbigrat:
f703fc96 671
126f3c5f
JH
672 perl -Mbigint -le 'print sqrt(33)'
673 perl -Mbigint -le 'print 2*255'
674 perl -Mbigint -le 'print 4.5+2*255'
675 perl -Mbigint -le 'print 3/7 + 5/7 + 8/3'
676 perl -Mbigint -le 'print 123->is_odd()'
677 perl -Mbigint -le 'print log(2)'
678 perl -Mbigint -le 'print 2 ** 0.5'
679 perl -Mbigint=a,65 -le 'print 2 ** 0.2'
95a2d02c 680 perl -Mbignum=a,65,l,GMP -le 'print 7 ** 7777'
126f3c5f
JH
681
682=head1 LICENSE
683
684This program is free software; you may redistribute it and/or modify it under
685the same terms as Perl itself.
686
687=head1 SEE ALSO
688
689Especially L<bigrat> as in C<perl -Mbigrat -le 'print 1/3+1/4'> and
690L<bignum> as in C<perl -Mbignum -le 'print sqrt(2)'>.
691
692L<Math::BigInt>, L<Math::BigRat> and L<Math::Big> as well
326f3c9d 693as L<Math::BigInt::Pari> and L<Math::BigInt::GMP>.
126f3c5f
JH
694
695=head1 AUTHORS
696
95a2d02c 697(C) by Tels L<http://bloodgate.com/> in early 2002 - 2007.
126f3c5f
JH
698
699=cut