All Projects → rgroshanrg → bigint

rgroshanrg / bigint

Licence: MIT license
bigint is a C++ library which can handle Very very Big Integers. It can calculate factorial of 1000000... it can go any big. It may be useful in Competitive Coding and Scientific Calculations which deals with very very large Integers. It can also be used in Decryption process. It has many inbuilt functions which can be very useful.

Programming Languages

C++
36643 projects - #6 most used programming language

Projects that are alternatives of or similar to bigint

BigNumber
A really long long long long long long number in C++
Stars: ✭ 37 (+8.82%)
Mutual labels:  biginteger, bigint, biginteger-cpp
BhimIntegers
BhimIntegers🚀 is a C++ library that is useful when we are dealing with BigIntegers💥💥. We can handle big integers (integers having a size bigger than the long long int data type) and we can perform arithmetic operations📘 like addition, multiplication, subtraction, division, equality check, etc📐📐. Also, there are several functions like factorial, …
Stars: ✭ 43 (+26.47%)
Mutual labels:  strings, biginteger, biginteger-library
string theory
Flexible modern C++ string library with type-safe formatting
Stars: ✭ 32 (-5.88%)
Mutual labels:  strings, string-manipulation
Cuerdas
String manipulation library for Clojure(Script)
Stars: ✭ 272 (+700%)
Mutual labels:  strings, string-manipulation
Mightystring
Making Ruby Strings Powerful
Stars: ✭ 28 (-17.65%)
Mutual labels:  strings, string-manipulation
Libft
42 library of basic C functions - queues, lists, memory operations and more 😄
Stars: ✭ 21 (-38.24%)
Mutual labels:  strings, string-manipulation
the-stringler
An OOP approach to string manipulation.
Stars: ✭ 36 (+5.88%)
Mutual labels:  strings, string-manipulation
Chr
🔤 Lightweight R package for manipulating [string] characters
Stars: ✭ 18 (-47.06%)
Mutual labels:  strings, string-manipulation
Str
str: yet another string library for C language.
Stars: ✭ 159 (+367.65%)
Mutual labels:  strings, string-manipulation
Stringz
💯 Super fast unicode-aware string manipulation Javascript library
Stars: ✭ 181 (+432.35%)
Mutual labels:  strings, string-manipulation
Util
A collection of useful utility functions
Stars: ✭ 201 (+491.18%)
Mutual labels:  strings, string-manipulation
Algorithms
🎓 Important Algorithms and their implementations
Stars: ✭ 30 (-11.76%)
Mutual labels:  competitive-programming, hactoberfest
klibcpp
kedixa's Cplusplus Library(timer, multiarray, unsigned_bigint, bigint, rational)
Stars: ✭ 17 (-50%)
Mutual labels:  biginteger, bigint
Base62
PHP Base62 encoder and decoder for integers and big integers with Laravel 5 support.
Stars: ✭ 16 (-52.94%)
Mutual labels:  biginteger, bigint
python-string-utils
A handy Python library to validate, manipulate and generate strings
Stars: ✭ 47 (+38.24%)
Mutual labels:  strings, string-manipulation
Twine
String manipulation, leveled up!
Stars: ✭ 496 (+1358.82%)
Mutual labels:  strings, string-manipulation
as-bignum
Fixed length big numbers for AssemblyScript 🚀
Stars: ✭ 49 (+44.12%)
Mutual labels:  biginteger, bigint
BigInteger
Be limited not by the size of your register but by the bulk of your RAM.
Stars: ✭ 13 (-61.76%)
Mutual labels:  biginteger, bigint
Cracking The Coding Interview
Solutions for Cracking the Coding Interview - 6th Edition
Stars: ✭ 35 (+2.94%)
Mutual labels:  strings, string-manipulation
UInt256
An UInt256 library written in Swift 4
Stars: ✭ 20 (-41.18%)
Mutual labels:  biginteger, bigint

bigint

Big Integer Library for C++

1 Million digits? 1 Billion? 1 Trillion? No Worries. This Library can handle any Integer of any Length.

drawing

bigint is a C++ library which can handle Very very Big Integers. It can calculate factorial of 1000000... it can go any big. It may be useful in Competitive Coding and Scientific Calculations which deals with very very large Integers. It can also be used in Decryption process. It has many inbuilt functions which can be very useful.


How to use it?

Download bigint header and include in your C++ program.

#include "bigint.h"     // with proper file path 

Declaring and Intializing Variables.

Declartion is done like making object of bigint class. Intialization can be done by passing String or Integer or Long type at Object creation.

bigint a("56654250564056135415631554531554513813");     // big integer initialization with String
bigint b("60820564691661355463515465564664568");        // big integer initialization with String
bigint d(956486133);                                    // big integer intialization with Integer

Addition

Addition can be done as it is done with general integer types of variables.

  • (Note : variable's value and declaration will be followed as it goes.)
bigint c = a + b;                         // Addition, with both operand as bigint
cout << c << std::endl;     // Output : 56715071128747796771095069997119178381

c = a + 56242;                            // Addition, with one operand as bigint and other as integer
cout << c << std::endl;     // Output : 56654250564056135415631554531554570055

c = 52 + 98;                              // Addition, with both operand as integers.
cout << c << std::endl;     // Ouput : 150

c = c + a + b;                            // Addition, with multiple operands
cout << c << std::endl;     // Output : 56715071128747796771095069997119178531

Subtraction

Subtraction can be done as it is done with general integer types variables.

c = a - b;                                 // Subtraction, with both operand as bigint
cout << c << std::endl;     // Ouput : 56593429999364474060168039065989849245

c = a - 56242;                            // Subtraction, with one operand as bigint and other as integer
cout << c << std::endl;     // Output : 56654250564056135415631554531554457571

c = 52 - 98;                              // Subtraction, with both operand as integers.
cout << c << std::endl;     // Output : -46

c = c - a - b;                            // Subtraction, with multiple operands
cout << c << std::endl;     // Output : -56715071128747796771095069997119178427

Multiplication

Multiplication can be done as it is done with general integer types variables.

c = a * b;                                 // Multiplication, with both operand as bigint
cout << c << std::endl;     // Output : 3445743511488768021543787806860750328299778111849236444610289955667677784

c = a * 56242;                            // Multiplication, with one operand as bigint and other as integer
cout << c << std::endl;     // Output : 3186348360223645168045949889963688965870746

c = 52 * 98;                              // Multiplication, with both operand as integers.
cout << c << std::endl;     // Output : 5096

c = c * a * b;                            // Multiplication, with multiple operands
cout << c << std::endl;     // Output : 17559508934546761837787142663762383673015669257983708921734037614082485987264

Division

Division can be done as it is done with general integer types variables.

c = a / b;                                 // Divison, with both operand as bigint
cout << c << std::endl;     // Output : 931

c = a / 56242;                            // Divison, with one operand as bigint and other as integer
cout << c << std::endl;     // Output : 1007329941397107773827949833426167

c = 98 / 56;                              // Divison, with both operand as integers.
cout << c << std::endl;     // Output : 1

c = a / b / c;                            // Divison, with multiple operands
cout << c << std::endl;     // Output : 931

Mod

Mod can be done as it is done with general integer types variables.

c = a % b;                                 // mod, with both operand as bigint
cout << c << std::endl;     // Output : 56654250564056135415631554531554513813

c = a % 56242;                            // mod, with one operand as bigint and other as integer
cout << c << std::endl;     // Output : 29399

c = 98 % 56;                              // mod, with both operand as integers.
cout << c << std::endl;        // output : 42

c = a % b % c;                            // mod, with multiple operands
cout << c << std::endl;     // Output : 41

Conditional Statements

Conditionals can be used as it is done with general integer types variables. Supports : > , < , >= , <= , == , !=

if(a > b) {
    cout << "a is greater than b" << std::endl;     // It executes
} else {
    cout << "a is smaller than b" << std::endl;     // It does not executes
}

if(a != b) {
    cout << "a is not equal to b" << std::endl;     // It executes
} else {
    cout << "a is equal to b" << std::endl;         // It does not executes
}

In-built Functions

to_bigint(string) or to_bigint(int) or to_bigint(long) - to bigint function

It takes one argument as string or int or long or long long and converts and return bigint of that particular argument provided.

b = to_bigint("56");

big_abs(bigint) - absolute function

It takes bigint as argument and return type is also bigint.

cout << big_abs(b) << std::endl;    // Output : 60820564691661355463515465564664568
b = to_bigint("-60820564691661355463515465564664568");
cout << big_abs(b) << std::endl;        // Output : 60820564691661355463515465564664568
b = big_abs(b);
cout << b << std::endl;             // Output : 60820564691661355463515465564664568

big_max(bigint, bigint) - maximum function

It takes two bigint as arguments and return type is also bigint, returns the maximum of both bigints.

cout << big_max(a, b) << std::endl;          // returns maximum of both bigints
// Output : 56654250564056135415631554531554513813

big_min(bigint, bigint) - minimum function

It takes two bigint as arguments and return type is also bigint, returns the minimum of both bigints.

cout << big_min(a, b) << std::endl;          // returns minimum of both bigints
// Output : 60820564691661355463515465564664568

big_pow(bigint, bigint) - power function

It takes two bigint as arguments and return type is also bigint, returns the first bigint argument to the power second bigint argument.

b = to_bigint("2");
cout << big_pow(a, b) << std::endl;            // return a to the power b bigint
// Output : 3209704106974854937901411896655926267350648828646359016173511958974807798969
b = to_bigint("60820564691661355463515465564664568");

big_sqrt(bigint) - square root function

It takes one bigint as arguments and return type is also bigint(floor value), returns the square root of the bigint.

cout << big_sqrt(a) << std::endl;               // returns sqrt of bigint
// Output : 7526901790514881921

big_log2(bigint) - log2 function

It takes one bigint as arguments and return type is also bigint(floor value), returns the log to base 2 of the bigint.

cout << big_log2(a) << std::endl;               // returns log to the base 2 bigint
// Output : 125

big_log10(bigint) - log10 function

It takes one bigint as arguments and return type is also bigint(floor value), returns the log to base 10 of the bigint.

cout << big_log10(a) << std::endl;              // returns log to the base 10 bigint
// Output : 37

big_logwithbase(bigint, bigint) - logwithbase function

It takes two bigints as arguments and return type is also bigint(floor value), returns the first arg. log to base of second arg. of the bigint.

cout << big_logwithbase(a, b) << std::endl;         // returns log of 'a' to the base 'b' bigint
// Output : 1

big_swap(bigint, bigint) - swap function

It takes two arguments as bigint and swaps them.

big_swap(a, b);
cout << a << "\t" << b << std::endl;    // Output : 56      56654250564056135415631554531554513813

big_gcd(bigint, bigint) - Greatest Common Divisor function (GCD or HCF)

It takes two bigint as arguments and return type is also bigint, returns the gcd of both as bigint.

cout << big_gcd(a, b) << std::endl;      // Output : 1

big_lcm(bigint, bigint) - Lowest Common Multiple function (LCM)

It takes two bigint as arguments and return type is also bigint, returns the lcm of both as bigint.

cout << big_lcm(a, b) << std::endl;     // Output : 3172638031587143583275367053767052773528

big_fact(bigint) - factorial function

It takes one bigint as argument and return type is also bigint, returns the factorial of arg. bigint.

a = to_bigint("15");
cout << big_fact(a) << std::endl;       // Output : 1307674368000

big_isPrime(bigint) - Prime number checker function

It takes one bigint as argument and return type is boolean, returns true if the bigint is prime or false in other cases.

a = to_bigint("67");
b = to_bigint("33");
cout << big_isPrime(a) << std::endl;      // Output : 1   (true)
cout << big_isPrime(b) << std::endl;      // Output : 0   (false)

big_reverse(bigint) - Reverse function

It takes one bigint as argumnet and return type is also bigint, returns bigint after reversing the digits on the bigint.

a = to_bigint("65894");
cout << big_reverse(a) << std::endl;            // Output : 49856

big_isPalindrome(bigint) - Palindrome checker

It takes one bigint as argument and return type is boolean, returns true if the bigint is palindromic bigint or false in other cases.

cout << big_isPalindrome(a) << std::endl;        // Output : 0  (false)
a = to_bigint("654456");
cout << big_isPalindrome(a) << std::endl;        // Output : 1   (true)

Increment and Decrement

Increment and Decrement can be done as it is done with general integer types of variables.

cout << a << "\t" << ++a << std::endl;              // Output : 654456  654457
cout << a << "\t" << --a << std::endl;              // Output : 654457  654456
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].