Git Product home page Git Product logo

biginteger's Introduction

BigInteger

Description

Implementation of long arithmetic on C++.

Operators

Addition

BigIntegerLibrary::BigInteger a, b, c;
c = a + b;
c += a;
c = a + 6;
c += 6;

Subtraction

BigIntegerLibrary::BigInteger a, b, c;
c = a - b;
c -= a;
c = a - 6;
c -= 6;

Multiplication

BigIntegerLibrary::BigInteger a, b, c;
c = a * b;
c *= a;
c = a * 6;
c *= 6;

Dividing

BigIntegerLibrary::BigInteger a, b, c;
c = a / b;
c /= a;
c = a / 6;
c /= 6;
c = a % b;
c %= a;
c = a % 6;
c %= 6;

Comparison

BigIntegerLibrary::BigInteger a(152);
BigIntegerLibrary::BigInteger b(22943);

if (a == b) cout << "A is equal to B";
if (a < b) cout << "A is less than B";
if (a > b) cout << "A is greater than B";
if (a >= b) cout << "A is greater than or equal to B";
if (a <= b) cout << "A is less than or equal to B";
if (a != b) cout << "A is not equal to B";

Stream operators

BigIntegerLibrary::BigInteger a, b;
cin >> a >> b;
cout << a * b;

Methods

to_string()

Converts the big integer to a string.

BigIntegerLibrary::BigInteger a(-152);
string str = a.to_string();

Functions

abs(BigInteger)

Absolute value.

BigIntegerLibrary::BigInteger a(-152);
cout << BigIntegerLibrary::abs(a); // 152

pow(BigInteger, long long)

Raises to the power of N.

BigIntegerLibrary::BigIntegert a = 19;
cout << BigIntegerLibrary::pow(a, 87); // ~1.784e+111

sqrt(BigInteger)

Return the int part of squared root.

BigIntegerLibrary::BigInteger a = 120;
cout << BigIntegerLibrary::sqrt(a); // [~10.954] = 10

gcd(BigInteger, BigInteger)

Return greatest common divisor of abs(a) and abs(b).

BigIntegerLibrary::BigInteger a = -30;
BigIntegerLibrary::BigInteger b = 12;
cout << BigIntegerLibrary::gcd(a, b); // gcd(30, 12) = 6

biginteger's People

Contributors

vocheretnyi avatar

Stargazers

 avatar  avatar  avatar

Watchers

 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.