bignum

How can I represent a very large integer in .NET?

Does .NET come with a class capable of representing extremely large integers, such as 100 factorial? If not, what are some good third party libraries to accomplish this? ...

Most efficient implementation of a large number class

When doing calculations on very large numbers where integral data types such as double or int64 falls short, a separate class to handle such large numbers may be needed. Does anyone care to offer an efficient algorithm on how best to do this? ...

Adding floats with gmp gives "correct" results, sort of ...

In the code below I use mpf_add to add the string representation of two floating values. What I don't understand at this point is why 2.2 + 3.2 = 5.39999999999999999999999999999999999999. I would have thought that gmp was smart enough to give 5.4. What am I not comprehending about how gmp does floats? (BTW, when I first wrote this I w...

Working with large numbers in PHP.

To use modular exponentiation as you would require when using the Fermat Primality Test with large numbers (100,000+), it calls for some very large calculations. When I multiply two large numbers (eg: 62574 and 62574) PHP seems to cast the result to a float. Getting the modulus value of that returns strange values. $x = 62574 * 62574; ...

How to implement big int in C++

Hi, I'd like to implement a big int class in C++ as a programming exercise. A class that can handle numbers bigger then a long int. I know that there are several open source implementations out there already, but I'd like to write my own. I trying to get a feel for what the right approach is. I understand that the general strategy i...

How do I process enormous numbers?

Suppose I needed to calculate 2^150000. Obviously that number is going to exceed the size of an int, float, or double. How can I make a data type that allows normal math functions but exceeds the basic number types? If this is a "depends which language you use" kind of deal. I will say C#. ...

How can I compute double factorials in Perl?

Given Wikipedia's discussion of Double Factorials, can anyone suggest where I might find a bignum version of this for Perl, or else suggest how it might be written? ...

Why does JRuby not recognize BigNums while Ruby does?

If I type this big integer: puts 9997836544.class.to_s and compile with ruby 1.86, it reports expectedly: BigNum while JRuby (1.1.4 in Netbeans) reports surprisingly: Fixnum I thought Java had a BigInteger class to correspond to the BigNum class in Ruby. If so, I would have expected JRuby and ruby to produce the same output. ...

Who does non-decimal bignums with floating radix point?

Nice as the Tcl libraries math::bignum and math::bigfloat are, the middle ground between the two needs to be addressed. Namely, bignums which are in different radices and have a radix point. At present math::bignum only handles integers (afaict) and math::bigfloat won't let you specify different radices to math::bigfloat::fromstr (ditt...

Unix Time Stamp and JavaScript Time; too big!

Hi there, I'm using the flot graphing library for jQuery, and it uses javascript time for any time series (to remind, that's milliseconds since Jan 1970. Unix time is seconds). My current code looks like this: foreach($decoded['results'] as $currentResult) { if($currentResult['from_user'] == $user) { $strippedTexts = $...

Arithmetic Operations on Very, Very Long Decimals

I've always been curious: how can I perform arithmetic operations on very long decimals--for example, calculating pi to the 3000th decimal place (especially in an imperative language)? ...

Square root of bignum using GMP

I need to get the square root of a 210 digit number accurately, I thought GMP was the right tool for the job, what am I doing wrong? #include <stdlib.h> #include <stdio.h> #include "gmp.h" int main (int argc, char *argv[]) { mpz_t sq_me, sq_out, test; mpz_init(sq_me); mpz_init(sq_out); mpz_init(test); mpz_set_str (sq_me, argv...

How can I sprintf a big number in Perl?

On a Windows 32-bit platform I have to read some numbers that, this was unexpected, can have values as big as 99,999,999,999, but no more. Trying to sprintf("%011d", $myNum) them outputs an overflow: -2147483648. I cannot use the BigInt module because in this case I should deeply change the code. I cannot manage the format as string, ...

Convert really big number from binary to decimal and print it

I know how to convert binary to decimal. I know at least 2 methods: table and power ;-) I want to convert binary to decimal and print this decimal. Moreover, I'm not interested in this `decimal'; I want just to print it. But, as I wrote above, I know only 2 methods to convert binary to decimal and both of them required addition. So, I'...

How can I get digits out of a Perl bignum?

I have a really big number in Perl. I use "bignum". How can I extract single digits out of this big number. For example if I have a number like this and what to get the 3rd digit from the end: 1029384710985234058763045203948520945862986209845729034856 -> 8 ...

Best bignum library to solve Project Euler problems in C++ ?

Hi, I am still a student, and I find project Euler very fun. sometimes the question requires calculations that are bigger than primitive types. I know you can implement it but I am too lazy to do this, So I tried few libraries, MAPM :: very good performance, but it provides only big floats, with the possibility to check if it is an i...

Sieve of Eratosthenes problem: handling really big numbers.

I'm solving Sphere's Online Judge Prime Generator using the Sieve of Eratosthenes. My code works for the test case provided. But.. as the problem clearly states: The input begins with the number t of test cases in a single line (t<=10). In each of the next t lines there are two numbers m and n (1 <= m <= n <= 1000000000, n-...

Convert Hex to Decimal when no datatype can hold the full number

Ok, so I am working with a PIC microprocessor, in C. It's a 16F, so it can't hold integers larger than 32bits (unsigned int32 is the largest datasize available) From a reader, I receive a 5 byte ID code. To transmit it, I have to encoded to BCD, digit by digit. I can't sprint it to a string, as it is larger that the data size, and can't...

Finding prime factors to large numbers using specially-crafted CPUs

My understanding is that many public key cryptographic algorithms these days depend on large prime numbers to make up the keys, and it is the difficulty in factoring the product of two primes that makes the encryption hard to break. It is also my understanding that one of the reasons that factoring such large numbers is so difficult, is ...

Arbitrary-precision arithmetic Explanation

I'm trying to learn C and have come across the inability to work with REALLY big numbers (i.e., 100 digits, 1000 digits, etc.). I am aware that there exist libraries to do this, but I want to attempt to implement it myself. I just want to know if anyone has or can provide a very detailed, dumbed down explanation of arbitrary-precision a...