Questions tagged [largenumber]

Very large numbers often occur in fields such as mathematics, cosmology, cryptography and statistical mechanics. That numbers are significantly larger than those ordinarily used in everyday life, for instance in simple counting or in monetary transactions. The term typically refers to large positive integers, or more generally, large positive real numbers, but it may also be used in other contexts.

In computer science, arbitrary-precision arithmetic, also called bignum arithmetic, multiple precision arithmetic, or sometimes infinite-precision arithmetic, indicates that calculations are performed on numbers which digits of precision are limited only by the available memory of the host system. This contrasts with the faster fixed-precision arithmetic found in most arithmetic logic unit (ALU) hardware, which typically offers between 8 and 64 bits of precision.

Several modern programming languages have built-in support for large numbers (also known as infinite precision integers or bignums), such as , , and . Other languages which do not support this concept as a top-level construct may have libraries available to represent very large numbers using arrays of smaller variables, such as and class or package.

Other languages have libraries available for arbitrary-precision integer and floating-point math. Rather than store values as a fixed number of binary bits related to the size of the processor register, these implementations typically use variable-length arrays of digits.

453 questions
4
votes
3 answers

Long ints in Fortran

I'm trying to work with large numbers (~10^14), and I need to be able to store them and iterate over loops of that length, i.e. n=SOME_BIG_NUMBER do i=n,1,-1 I've tried the usual star notation, kind=8 etc. but nothing seems to work. Then I checked…
Samizdis
  • 1,591
  • 1
  • 17
  • 33
4
votes
1 answer

In javascript, how do I deal with large numbers efficiently in a loop?

My instructions were "for i from 1 to n, do i % m and return the sum. You'll need to get a little clever with performance, since n can be a very large number" The program below works fine with small numbers. How can I make it efficient with large…
Wilfredo
  • 137
  • 1
  • 9
4
votes
1 answer

how python stores value for very very large integers

Look at this simple python program def fib1(n): a, b = 0, 1 while b < n : print b, a, b = b, a+b if __name__ == '__main__': import sys fib1(int(sys.argv[1])) If run this code as python fibo.py…
mohit
  • 1,011
  • 2
  • 16
  • 26
4
votes
3 answers

How to find perfect squares in a range efficiently when the inputs are large numbers in Python

The question is how to find perfect squares in a given range efficiently when the inputs are very large numbers. My solution is giving Time Limit Exceeded error. I have already checked the following links, but they didn't solve my problem: - Python…
titan7585
  • 300
  • 1
  • 5
  • 9
4
votes
1 answer

Can I Increase Vector Precision in THREE.js?

In THREE.js, I occasionally find myself wishing for better control over vector precision, especially when working with large floats, such as in a solar system. Is there any way to do this? In the linked example, I'm building a simple solar system…
Zob
  • 460
  • 4
  • 14
4
votes
3 answers

How to calculate the mod of large exponents?

For example I want to calculate (reasonably efficiently) 2^1000003 mod 12321 And finally I want to do (2^1000003 - 3) mod 12321. Is there any feasible way to do this?
user3063864
  • 661
  • 2
  • 7
  • 18
4
votes
2 answers

Decompose integers larger than 100 digits

X and Y are integers larger than 100 digits. Find the integer P which is within the range [X, Y[ and that guaranties the "best" prime decomposition (i.e. the decomposition with the most unique prime factors). What I've done is just check the…
Jonas
  • 1,019
  • 4
  • 20
  • 33
4
votes
1 answer

Operations with large numbers

I have some numbers a_i (for i=1 to 10000). I need to compute exp(a_i)/sum(exp(a_j)) using matlab. Of course, it is impossible to calculate straight away. I found some tricks, the most interesting being: "Suppose we want to find exp(7.0873e002).…
bigTree
  • 2,103
  • 6
  • 29
  • 45
4
votes
2 answers

How can you handle absurdly large numbers?

There are some scenarios where programmers need or want to find grossly large numbers. These are often so large that they defy the programmer's comprehension. I'm talking about things like the largest known prime number (with 12978189 digits) and…
asteri
  • 11,402
  • 13
  • 60
  • 84
4
votes
2 answers

a more simple big adder in c#?

I just had the task in school to write a big adder. Meaning a method that can put very large numbers together. We had 10 minutes and I did complete it on time. The teacher approved it. I am not too satisfied with the result though, and I thought I…
CasperT
  • 3,425
  • 11
  • 41
  • 56
4
votes
1 answer

What data structure to use with arbitrarily large integer numbers?

Possible Duplicate: What data-structure should I use to create my own “BigInteger” class? Out of pure interest, I am trying to design a type that can hold an arbitrarily large integer. I want to support four basic operations [+, -, *, /] and…
oleksii
  • 35,458
  • 16
  • 93
  • 163
4
votes
5 answers

Best way to store large base B numbers?

What is the best way to store large base B numbers so that the operations like right shift and checking the least significant bit can be done efficiently? Actually, I have came across an interview question which says that Given two numbers N and K…
Ravi Gupta
  • 6,258
  • 17
  • 56
  • 79
3
votes
3 answers

what options are there for representing numbers with more than 2^81 digits?

I came across an interesting math problem that would require me to do some artithmetic with numbers that have more than 281 digits. I know that its impossible to represent a number this large with a system where there is one memory unit for each…
Letseatlunch
  • 2,432
  • 7
  • 28
  • 33
3
votes
1 answer

Factorial digit sum in APL (Project Euler 20)

First I found +/⍎¨⍕(!8) and it gave me the result 9. But if I do 100!, as the number is big, I am not able to get that. With ⍎¨⍕(!100) I am getting a syntax error: ⍎SYNTAX ERROR Is there any other way to solve the problem or can you suggest me some…
3
votes
3 answers

Calculating 3^3^3^3 (very large exponent / how did Wolfram do it?)

I can't find a right algorithm / struct to calculate the number simply in C or Go. However, a class can easily be created in Python. At first glance, the calculation seems to be very straight forward. However, when you look at the sample calculation…
Polv
  • 1,918
  • 1
  • 20
  • 31