You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BhimIntegers is a C++ library that is useful when we are dealing with BigIntegers. We can handle big integers (integers having a more significant size than the long long data type). We can perform arithmetic operations like addition, multiplication, subtraction, division, equality check, etc. Also, there are several functions like factorial, reverse. We can check that a number is a palindromic number, counting occurrences, etc. It has some conversion options to convert a string to bhimInteger etc. Overall this library is handy for extensive computing results.
Usage
Download the "BhimInteger.h" header .Then #include it inside your code:
#include"BhimInteger.h"// the actual path may vary
Declaring A Variable
BhimInteger n1; //n1 defined with value 0
BhimInteger n2(123); //n2 defined with value int value
BhimInteger n3((longlongint)1234567898765432); //n3 defined with value long long int value
BhimInteger n4("7832467326423873423435"); //n4 defined with string value
BhimInteger n5(n3);
Converting to BhimNumbers
int num1 = -321;
longlongint num2 = -9876543219876543;
string str1 = "-2112321321321312421534365777";
BhimInteger n6 = to_Bhim(num1); //converting int to BhimInteger
BhimInteger n7 = to_Bhim(num2); //converting long long int to BhimInteger
BhimInteger n8 = to_Bhim(str1); //converting string to BhimInteger
cout<<"Check n3 != n5: "<<(bool)(n3 != n5)<<endl; //Checking if value of both are different
cout<<"Check n3 == n5: "<<(bool)(n3 == n5)<<endl; //Checking if value of both are same
cout<<"Maximum: "<<maxBhim(n1, n2)<<endl; //Maximum of two Numbers
cout<<"Minimum: "<<minBhim(n1, n2)<<endl; //Minimum of two Numbers
cout<<"absolute: "<<absBhim(n1)<<""<<absBhim(n2)<<endl; //Absolute value of a number
cout<<"Factorial: "<<factBhim(n1)<<""<<factBhim(n2)<<endl; //Factorial of a number
cout<<"Reverse: "<<revBhim(n3)<<endl; //Reverse a number
cout<<"Counting the occurance of a digit: "<<countBhim(n9,6)<<endl; //Counting the occurance of a digit
cout<<"Erasing all occurance of a digit: "<<eraseBhim(n9,4)<<endl; //Erasing all occurances of a digit
cout<<"isPaliBhim: "<<(bool)isPaliBhim(n9)<<endl; //Checking if a number is palindrome
cout<<"sorting the digits: "<<sortBhim(n9)<<endl; //sort the digits of a number
cout<<"Finds power: "<<powBhim(n3, n2)<<endl; //finds x to the power y, where x and y is any int. Returns Integer value in form of string