biginteger

Calculating the square of BigInteger

Hi, I'm using .NET 4's System.Numerics.BigInteger structure. I need to calculate the square (x2) of very large numbers - millions of decimal digits. If x is a BigInteger, What is the time complexity of: x*x; or BigInteger.Pow(x,2); ? How can multiply such big numbers in the fastest way using .NET 4 BigInteger? Is there an imple...

Is there is some mathematical "optimum" base that would speed up factorial calculation?

Is there is some mathematical "optimum" base that would speed up factorial calculation? Background: Just for fun, I'm implementing my own bignum library. (-: Is this my first mistake? :-). I'm experimenting with various bases used in the internal representation and regression testing by printing out exact values (in decimal) for n facto...

Dividing large integer by large integer

Guys I'm working on class called LINT (large int) for learning purposes, and everything went ok till know. I'm stuck on implementing operator/(const LINT&). The problem here is that in when I want to divide LINT by LINT I'm getting into recursive fnc invocation i.e: //unfinished LINT_rep LINT_rep::divide_(const LINT_rep& bottom)const {...

java Biginteger BigDecimal

Is there any way to convert a BigInteger into a BigDecimal? i know you can go from DEC to INT but i cant find a method to go the other way around in JAVA. thanks in advance. ...

BSD Licensed Big Integer C lib with fast modpow

I'm searching a fast (specially the p^n mod g operation, should be implemented with montgomery) big integer library. I know there is GMP but GMP is LGPL which doesn't fit my requirements. I tried http://www.acme.com/software/bigint/ and tried to optimize the modpow in there. But do to the fact that the data is stored with base 2^32 it i...

How to implement c=m^e mod n for enormous numbers?

Hi, I'm trying to figure out how to implement RSA crypto from scratch (just for the intellectual exercise), and i'm stuck on this point: For encryption, c = me mod n Now, e is normally 65537. m and n are 1024-bit integers (eg 128-byte arrays). This is obviously too big for standard methods. How would you implement this? I've been rea...

Groovy BigInteger to string

I am using i = value.toBigInteger() i.toString(32).toUpperCase() to convert a 16 digit 'number' to characters for use in a serial Is there any way to force this to use the A-Z + 2-7 notation rather than 0-9 + A-V?? ...

Groovy to Biginteger

As the reverse of i.toString(32) is there a better (i.e. working) method to use instead of i = Integer.parseInt(string, 32) to create a BigInteger, as the string I want to pass is 11 'characters' long? (D4KJI9QLC3L) gives me java.lang.NumberFormatException: For input string: "D4KJI9QLC3L" Parameters:{val=14800099002200181, str=D4KJI9...

How does this integer encoding work?

In this code golf question, there is a python answer that encodes the lengths of all integers from 1 to 99 in english to a big number: 7886778663788677866389978897746775667552677566755267756675527886778663788677866355644553301220112001 To get the length of n, you just have to calculate 3 + (the_big_number / (10**n)) % 10. How does thi...

Large integer and arbitrary/multi precision floats for Vala

Is there a way to use big integers or arbitrary precision types in vala? ...

what type to use when long double is not enough?

Hey, I'm writing a program that assigns prime numbers to each entry of a matrix and then I'll need to multiply some of them. The resulting number grows rapidly and I'm at a loss as to which type to use, as I'm getting "wrap-around" with long double :S All the help is appreciated. -Pickel ...

C++ - How to work with BIG numbers?

Possible Duplicates: BigInt in C? How to implement big int in C++ How do we work with big numbers without making use of external libraries and functions? Some problems are as follows: What is the sum of the digits of the number 21000? Work out the first ten digits of the sum of the following one-hundred 50-digit numbers. ...

What is an efficient way to convert a bignum type structure to a human readable string?

Hello all, I've got a bit of a problem. In order to grow in my knowledge of C, I've decided to try to implement a basic bigint library. The core of the bigint structure will be an array of 32 bit integers, chosen because they will fit in a register. This will allow me to do operations between digits that will overflow in a 64 bit integ...

BigInteger.pow() with a BigInteger

I am tying to throw an exception when a BigInteger is greater than Integer.MAX_VALUE. It will not allow me to throw that exception for the exponent case. I am not sure how to get it to throw an exception when the biginteger value is too large to pass into the BigInteger.pow() method. Thanks in advance. here is the toPostfix method: ...

Calculate square root of a BigInteger (System.Numerics.BigInteger)

.NET 4.0 provides System.Numerics.BigInteger, I need to compute the square root(a reasonable aproximation atleast) of a BigInteger, as to not reimplement the wheel, does anyone have a nice extension methods for this ? ...

Optimise arithmetic operations on very large numbers

I want to compute the function H(n) where H(0)=0; H(i)=H(i-1)×A+Ci mod B; 10<=A,B<=10^15; C is an array of n elements But it is taking too much time...any better way of doing this..Please help public BigInteger H(int no) { if(no>0) { bi=H(no-1); bi=bi.multiply(BigInteger.valueOf...

How to assign the largest n bit unsigned integer to a BigInteger in Java

I have a scenario where I'm working with large integers (e.g. 160 bit), and am trying to create the biggest possible unsigned integer that can be represented with an n bit number at run time. The exact value of n isn't known until the program has begun executing and read the value from a configuration file. So for example, n might be 1...

Large integers in javascript (more the 2^53-1)

What is general principals to operate with large integers in javascript? Like in libraries for bigint? How i do it by myself? ...

Handling integer out of range in bash

I have collected vmstat data in a file . It gives details about free, buffer and cache . SInce i'm interested in finding the memory usage , I should do the following computation for each line of vmstat output -- USED=TOTAL - (FREE+BUFFER+CACHE) where TOTAL is the total RAM memory and USED is the instantaneous memory value. TOTAL memory ...

How do BigNums implementations work?

I wanted to know how the BigInt and other such stuff are implemented. I tried to check out JAVA source code, but it was all Greek and Latin to me. Can you please explain me the algo in words - no code, so that i understand what i am actually using when i use something from the JAVA API. regards ...