biginteger

Should I use a big INT or regular INT in MySQL to store a timestamp?

Should I be using a big integer or a regular integer in MySQL to store a timerstamp in? I plan on storing it in an INT and not the built in timestamp or datetime so which INT type should I use? ...

Really big number

First of all apologies if there is already a topic like this but I have not found... I need to know how to handle a really big number such as the result of 789^2346: #include <iostream> #include <cmath> using namespace std; int main () { cout << pow(789,2346) << endl; } ...

how java.bigInteger valueOf works ?

I'm making a project concerned big numbers without BigInteger, BigDecimal etc. I've managed to do all the basics but now I need to add ability to count factorials. My BigNumber stores data as int[] . Here's a sample solution with BigInteger but I can't use it without having the actual value of my number. BigInteger n = BigInteger.O...

BigInteger.valueOf() limits

Does valueOf for BigInteger have any limitations ? I'm not sure but read somewhere, that given number can be of length = long only. ...

What complexity are operations on Java 7's BigInteger?

What complexity are the methods multiply, divide and pow in BigInteger currently? There is no mention of the computational complexity in the documentation (nor anywhere else). ...

Does BigInteger ever overflows ?

The API docs says All of the details in the Spec concerning overflow are ignored, as BigIntegers are made as large as necessary to accommodate the results of an operation. Does this implies BigInteger will never overflow assuming you have sufficient memory available ? If so why do we let some "type" overflow and some don't ? As ...

Optimizing Karatsuba Implementation (C#)

So, I'm trying to improve some of the operations that .net 4's BigInteger class provide since the operations appear to be quadratic. I've made a rough Karatsuba implementation but it's still slower than I'd expect. The main problem seems to be that BigInteger provides no simple way to count the number of bits and, so, I have to use BigI...

What data-structure should I use to create my own "BigInteger" class?

As an optional assignment, I'm thinking about writing my own implementation of the BigInteger class, where I will provide my own methods for addition, subtraction, multiplication, etc. This will be for arbitrarily long integer numbers, even hundreds of digits long. While doing the math on these numbers, digit by digit isn't hard, wha...

C#: How Should I Handle Arithmetic with Huge Numbers?

I'm writing an app which involves arithmetic with humongous numbers, with very many digits. I've previously written a class that simplifies handling big numbers by defining them as strings and then using slow arithmetic string functions. Is this the best way to do it? If not, how should I approach this problem? Does C# have anything buil...

Pros and cons of ways of storing an unsigned int without an unsigned int data type

I have values that are 64-bit unsigned ints, and I need to store them in mongodb, which has no unsigned int type. I see three main possibilities for storing them in other field types, and converting on going in and out: Using a signed int is probably easiest and most space efficient, but has the disadvantage that they're not human reada...

How to generate a random BigInteger value in Java?

I need to generate arbitrarily large random integers in the range 0 (inclusive) to n (exclusive). My initial thought was to call nextDouble and multiply by n, but once n gets to be larger than 253, the results would no longer be uniformly distributed. BigInteger has the following constructor available: public BigInteger(int numBits, R...

Visual C++ BigInt and SecureRandom? Is there a BigInt library with modPow?

I have to port some crypto code to visual c++ from java which (visual c++) I am not very familiar with. I found a library at http://sourceforge.net/projects/cpp-bigint/ that I can use for big integers. However it does not have an equivalent to javas SecureRandom class. I did find a project in c++ called beecrypt but could not get it ...

How to work with big numbers in PHP?

How to work with big numbers in PHP? such as (6*27^0+17*27^1+11*27^2+18*27^3+25*27^4+4*27^5)^65537 ...

Convert arbitrary size of byte[] to BigInteger[] and then safely convert back to exactly the same byte[], any clues?

I believe conversion exactly to BigInteger[] would be optimal in my case. Anyone had done or found this written in Java and willing to share? So imagine I have arbitrary size byte[] = {0xff,0x3e,0x12,0x45,0x1d,0x11,0x2a,0x80,0x81,0x45,0x1d,0x11,0x2a,0x80,0x81} How do I convert it to array of BigInteger's and then be able to recover it b...

XSLT big integer (int64) handling msxml

When trying to do math on an big integer (int64) large number in xslt template I get the wrong result since there is no native 64-bit integer support in xslt (xslt number is 64-bit double). I am using msxml 6.0 on Windows XP SP3. Are there any work around for this on Windows? <tables> <table> <table_schem>REPADMIN</table_schem> ...

The best cross platform (portable) arbitrary precision math library

Dear ninjas / hackers / wizards, keywords: bignum, bigint, GMP, MPFR, decNumber, BigInteger, BigDecimal, java.math.BigInteger, java.math.BigDecimal, System.Numerics.BigInteger I'm looking for a good arbitrary precision math library in C or C++. Could you please give me some advices / suggestions? The primary requirements: It MUST ha...

Switch to BigInteger if necessary

I am reading a text file which contains numbers in the range [1, 10^100]. I am then performing a sequence of arithmetic operations on each number. I would like to use a BigInteger only if the number is out of the int/long range. One approach would be to count how many digits there are in the string and switch to BigInteger if there are t...

How to get the nth root of big numbers in C++?

Is there a C++ library that can take nth roots of big numbers (numbers than can't fit in an unsigned long long)? ...

Why doesn't my processor have built-in BigInt support?

As far as I understood it, BigInts are usually implemented in most programming languages as arrays containing digits, where, eg.: when adding two of them, each digit is added one after another like we know it from school, e.g.: 246 816 * * ---- 1062 Where * marks that there was an overflow. I learned it this way at school and all B...

How to initialize a BigInteger in C#?

Hi, Can someone show me how to use the System.Numerics.BigInteger datatype? I tried using this as a reference - http://msdn.microsoft.com/en-us/library/system.numerics.biginteger%28VS.100%29.aspx But System.Numerics namespace isn't there on my computer. I have installed VS2010 Ultimate RC and i have .NET Framework 4.0. Can someone guid...