Giter Site home page Giter Site logo

massimo-marino / bigint Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 241 KB

C++17 implementation of arbitrary precision integer arithmetic

License: MIT License

CMake 10.59% C++ 87.29% Julia 2.12%
cpp cpp17 cpp1z biginteger bigint arbitrary-precision arbitrary-precision-integers googletest karatsuba

bigint's Introduction

bigint

C++17 implementation of arbitrary precision integer arithmetic.

This implementation is a re-implementation from:

https://sites.google.com/site/indy256/algo_cpp/bigint

However, this site is no more reachable.

You can get back past snapshots from the Internet Archive:

https://web.archive.org/web/20210301000000*/https://sites.google.com/site/indy256/algo_cpp/bigint

March 19 2021:

https://web.archive.org/web/20210319023614/https://sites.google.com/site/indy256/algo_cpp/bigint

October 24 2011:

https://web.archive.org/web/20111024050800/https://sites.google.com/site/indy256/algo_cpp/bigint

February 8 2011:

https://web.archive.org/web/20110208155854/https://sites.google.com/site/indy256/algo_cpp/bigint

Snapshot from March 19 2921 can be found in the folder src/original

Requirements

cmake 3.26.3 is used to compile the sources.

The cmake files compile with -std=c++17.

The unit tests are implemented in googletest: be sure you have installed googletest to compile.

To compile the example fibonacci, you need to install Boost's libboost-filesystem-dev, libboost-program-options-dev.

Install and Run Unit Tests

$ git clone https://github.com:massimo-marino/bigint.git
$ cd bigint
$ mkdir build
$ cd build
$ cmake ..
$ make
$ cd src/unitTests
$ ./bigint-unit-tests

Example: Fibonacci

To run the example:

$ cd build/src/fibonacci
$ ./fibonacci --help
$ ./fibonacci -n 1000000
[main] fib(1000000) of length 208988 digits written to file fib-1000000.txt
$

If you want to verify the results, there's a Julia script fib.jl in src/fibonacci/julia/

From there (and after having installed Julia), run:

$ julia -i fib.jl

julia> fib(100)
354224848179261915075

julia> fib(1000000)
354224848179261915075...omitted...411568996526838242546875

julia>

How to Use it

See the source code and the unit tests for examples of use.

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.