GithubHelp home page GithubHelp logo

p5-math-bigint-lite's Introduction

NAME

Math::BigInt::Lite - What Math::BigInts are before they become big

SYNOPSIS

use Math::BigInt::Lite;

my $x = Math::BigInt::Lite->new(1);

print $x->bstr(), "\n";                     # 1
$x = Math::BigInt::Lite->new('1e1234');
print $x->bsstr(), "\n";                    # 1e1234 (silently upgrades to
                                            # Math::BigInt)

DESCRIPTION

Math::BigInt is not very good suited to work with small (read: typical less than 10 digits) numbers, since it has a quite high per-operation overhead and is thus much slower than normal Perl for operations like:

my $x = 1 + 2;                          # fast and correct
my $x = 2 ** 256;                       # fast, but wrong

my $x = Math::BigInt->new(1) + 2;       # slow, but correct
my $x = Math::BigInt->new(2) ** 256;    # slow, and still correct

But for some applications, you want fast speed for small numbers without the risk of overflowing.

This is were Math::BigInt::Lite comes into play.

Math::BigInt::Lite objects should behave in every way like Math::BigInt objects, that is apart from the different label, you should not be able to tell the difference. Since Math::BigInt::Lite is designed with speed in mind, there are certain limitations build-in. In praxis, however, you will not feel them, because everytime something gets to big to pass as Lite (literally), it will upgrade the objects and operation in question to Math::BigInt.

Math library

Math with the numbers is done (by default) by a module called Math::BigInt::Calc. This is equivalent to saying:

use Math::BigInt::Lite lib => 'Calc';

You can change this by using:

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

The following would first try to find Math::BigInt::Foo, then Math::BigInt::Bar, and when this also fails, revert to Math::BigInt::Calc:

use Math::BigInt::Lite lib => 'Foo,Math::BigInt::Bar';

See the respective low-level math library documentation for further details.

Please note that Math::BigInt::Lite does not use the denoted library itself, but it merely passes the lib argument to Math::BigInt. So, instead of the need to do:

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

you can roll it all into one line:

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

Use the lib, Luke!

METHODS

new

$x = Math::BigInt::Lite->new('1');

Create a new Math::BigInt:Lite object. When the input is not of an suitable simple and small form, an object of the class of $upgrade (typically Math::BigInt) will be returned.

All other methods from BigInt and BigFloat should work as expected.

BUGS

Please report any bugs or feature requests to bug-math-bigint at rt.cpan.org, or through the web interface at https://rt.cpan.org/Ticket/Create.html?Queue=Math-BigInt-Lite (requires login). We will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc Math::BigInt::Lite

You can also look for information at:

LICENSE

This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

Math::BigFloat and Math::BigInt as well as Math::BigInt::Pari and Math::BigInt::GMP.

The bignum module.

AUTHORS

p5-math-bigint-lite's People

Contributors

pjacklam avatar rafl avatar tels avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.