I am trying to place a big number in a C++ variable. The number is 600851475143
I tried unsigned long long int but got an error saying it the constant was too big. I then tried a bigInt library called BigInt -> http://mattmccutchen.net/bigint/
The problem is I can't compile the code as I get many errors regarding the lib.
undefined reference to `BigInteger::BigInteger(int)' <-- lot's of these.
Here is my code so far:
#include "string"
#include "iostream"
#include "bigint/NumberlikeArray.hh"
#include "bigint/BigUnsigned.hh"
#include "bigint/BigInteger.hh"
#include "bigint/BigIntegerAlgorithms.hh"
#include "bigint/BigUnsignedInABase.hh"
#include "bigint/BigIntegerUtils.hh"
using namespace std;
int main() {
//unsigned long int num = 13195;
//unsigned long long int num = 600851475143;
BigInteger num = 13195;
int divider = 2;
//num = 600851475143;
while (1) {
if ((num % divider) == 0) {
cout << divider << '\n';
num /= divider;
}
else
divider++;
if (num == 1)
break;
}
}
If I put a smaller number and don't use the BigInt lib this program runs fine. Any help will be appreciated :D
The BIGINT data type is a machine-independent method for representing numbers in the range of -2 63-1 to 2 63-1. ESQL/C provides routines that facilitate the conversion from the BIGINT data type to other data types in the C language. The BIGINT data type is internally represented with the ifx_int8_t structure.
A Googolplex is considered to be the biggest number in the world. It is written as 10googol. The number 10googol can also be expressed in the exponential format that will equal 1010^100. While writing the number googol in normal number writing format the probability of losing count is very high.
In the number system, the numbers which are ordinarily bigger or greater than the other numbers are called large numbers. For example, 1 lakh, 1 million, 1 billion, etc. are big numbers which we do not use in daily life. These big numbers are basically denoted in standard form.
You can specify an integer literal as long by the suffix L.
You can specify an integer literal as long long by the suffix LL.
#include <iostream>
int main()
{
long long num = 600851475143LL;
std::cout << num;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With