Giter VIP home page Giter VIP logo

infinity's Introduction

infinity: an arbitrary precision arithmetic library
a signed arbitrary precision arithmetic library

infinity, as of present, is by no means a replacement for any serious work, it is a weekend hack at best. Please proceed with extreme caution. You have been warned!

contents

  1. usage
  2. tests
  3. example
  4. warning
  5. author

usage

  1. Build libInfinity.a using make all in the src directory.
  2. Copy the header files and libInteger.a file to your project.
  3. Include the header files as per requirement in your source file.
  4. Compile with -L$(LIB) and -lInfinity flags where LIB is the directory where libInfinity.a resides in.

tests

Run make testInteger in the src directory to compile the sanity checks. Execute the generated executable with ./test.out.

example

integer

#include <iostream>
#include "Integer.h"

int main() {
    Integer a("80");
    Integer b("4");
    Integer c = 11;
    Integer d = 100;

    std::cout << "a :: " << a;
    std::cout << "b :: " << b;
    std::cout << "c :: " << c;
    std::cout << "d :: " << d;

    std::cout << "a <= b :: " << (a <= b) << std::endl;
    std::cout << "a < b :: " << (a < b) << std::endl;
    std::cout << "a >= b :: " << (a >= b) << std::endl;
    std::cout << "a > b :: " << (a > b) << std::endl;
    std::cout << "a == b :: " << (a == b) << std::endl;
    std::cout << "a != b :: " << (a != b) << std::endl;

    std::cout << "-a :: " << -a;
    std::cout << "a + b :: " << a + b;
    std::cout << "a - b :: " << a - b;
    std::cout << "a * b :: " << a * b;
    std::cout << "a / b :: " << a / b;
    std::cout << "a % b :: " << a % b;
    std::cout << "Integer::pow(c, d) :: " << Integer::pow(c, d);

    return 0;
}

Which results in:

a :: Integer(+80)
b :: Integer(+4)
c :: Integer(+11)
d :: Integer(+100)
a <= b :: 0
a < b :: 0
a >= b :: 1
a > b :: 1
a == b :: 0
a != b :: 1
-a :: Integer(-80)
a + b :: Integer(+84)
a - b :: Integer(+76)
a * b :: Integer(+320)
a / b :: Integer(+20)
a % b :: Integer(+0)
Integer::pow(c, d) :: Integer(+137806123398222701841183371720896367762643312000384664331464775521549852095523076769401159497458526446001)

float

work in progress

warning

This a pet project to explore arbitrary precision arithmetic. If you need arbitrary precision arithmetic, consider using something more mature like GMP.

author

Sayan Goswami (c) 2018

infinity's People

Contributors

say4n avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

infinity's Issues

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.