biginteger

Recommendation on big integer calculation library.

Could your recommend some good big integer calculation library in C/C++/Java and it is better to support logarithmetic. Thanks. ...

Fastest 128 bit integer library

I am working on a CPU-heavy numerical computation app. Without going into many details, it's a computational math research project that involves computing a certain function f(x) for large integer x. Right now everything is implemented in C++ in x64 mode, using native 64-bit ints. That limits me to x<2^64~1.8*10^19. I want to go furthe...

How do I generate a random n digit integer in Java using the BigInteger class?

I am unsure about how to generate a random n digit integer in Java using the BigInteger class. ...

Randomizing a BigInteger

I'm looking to randomize a BigInteger. The intent is to pick a number from 1 to 8180385048. Though, from what I noticed, the BigInteger(BitLen, Random) does it from n to X2-1, I'd want some unpredictable number. I tried to make a method that would do it, but I keep running into bugs and have finally given in to asking on here. :P Does an...

How to add two numbers of any length in java?

Hi All, How to add two numbers of any length in java? Say for example, in java long size is 64 bit. So the maximum range is -9223372036854775808 to 9223372036854775807. Am i right? So if we want to add a number which is greater than this like below, i got a error " Integer Number too large" long a = 9223372036854775807L; lon...

What is the best way to check for infinity in a Perl module?

In one of my modules, I have to deal with the concept of infinity. To date, I have been using 9**9**9 as positive infinity, and this seems to work well, is fast, and seems to be what perl's internals use as infinity. However, things get a bit dicey if a user of my module decides to use one of the big number modules (like use bigint;)...

Creating a BigInteger Method

Is there any way to create a BigInteger Method? I want to have a method of return type BigInteger. ...

Using BigInteger Multiply operator

Hello, I was wondering if there was a way to multiply BigInteger variables together, because the * operator cannot be applied to BigInteger. So I was wondering if it was possible to multiply two BigIntegers together without using the * operator. ...

Converting from Integer, to BigInteger

Hello, I was wondering if there was any way to convert a variable of type Integer, to BigInteger. I tried typecasting the Integer variable, but i get an error that says inconvertible type. ...

Implementing primality test in Java using BigInteger

I am trying to implement either the Fermat, Miller-Rabin, or AKS algorithm in Java using the BigInteger class. I think I have the Fermat test implemented except that the BigInteger class doesn't allow taking BigIntegers to the power of BigIntegers (one can only take BigIntegers to the power of primitive ints). Is there a way around this...

Implementation of Fermat's primality test in Java

Who wants to help me with my homework? I'm try to implement Fermat's primality test in Java using BigIntegers. My implementation is as follows, but unfortunately it doesn't work. Any ideas? public static boolean checkPrime(BigInteger n, int maxIterations) { if (n.equals(BigInteger.ONE)) return false; BigInteger a; ...

Multiplication of two extremly large integers in array

Multiplication of two integers, like a = 38473847837483473894283749832938293872389472847389243847347 b = 92892382019283923829302392830923890 stored as a[0] = 3, a[1] = 8 ... I want to multiply these two over using efficient algorithm (note I stored them in array A and array B). And I want store result in RES[]. How can I do, ...

Little glitch in implementing RSA algorithm

I am trying to implement the RSA algorithm, but for some reason my code below doesn't produce correct results (note that only the relevant code is shown). BigInteger n = p.multiply(q); BigInteger totient = (p.subtract(BigInteger.ONE)).multiply(q.subtract(BigInteger.ONE)); Random rand = new Random(); BigInteger e; do { e = new BigInteg...