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
-3
votes
2 answers

How can I find out how much storage it would take to store every number between 1 and 2^100?

I am complete beginner when it comes to working with large numbers in code and I know this is definitely the wrong approach but this is what I started with. import tqdm try: total = 0 for num in tqdm.tqdm(range(2**100), total=2**100): …
Andres
  • 21
  • 4
-3
votes
3 answers

Can't calculate value in Python

I am trying to calculate value of this expression: int((1770246808796936040 * 1103515245 + 12345 / 65536) % 32768) And it gives 0. Without int cast, it is 0 too. Does anyone know why it so? Are these numbers too big for Python? Is any way to handle…
Bakerelly
  • 5
  • 1
-3
votes
3 answers

Finding solutions for a given pair (number of factors, number of prime factors)

I have been given x and k, where x is the number of factors of a number A, and k is the number of prime factors of A. Given x and k, I have to find out whether such an A exists. For example: INPUT : 4 2 OUTPUT : 1 Since 6 is a number that has 4…
Shrey Tripathi
  • 210
  • 2
  • 7
-3
votes
1 answer

Finding out if a big number is a perfect square numbers using C#

Is there a fast and simple way to write a program in C#, that finds out if a big (something like 25 digits big) number is a perfect square or not? Perfect squares are the numbers: 0^2=0,1^2=1,2^2=4,3^2=9,4^2=16,...
-3
votes
1 answer

avoiding overflow while multiplying very large integer in c++

The other day I was solving one multiplication programming problem in which multiplicand(a1,a2,..an) can be 1<= ai <= 10^9 . So my question is how to multiply those numbers so that they'll always remain in (long long) range in C++. Should I use…
SevenDante
  • 21
  • 3
-3
votes
2 answers

Finding sum of digits of a large factorial

Problem In the above problem, given a positive integer n it is intended to find the sum of all the digits in n!. So here is my java code for it: public static void main (String[] args) throws java.lang.Exception { Scanner sc = new…
yobro97
  • 1,125
  • 8
  • 23
-3
votes
1 answer

Adding large numbers returns strange, large numbers

I am trying to do some calculations in Fortran that looks like: large number (order E40) - large number (order E40) I should get back zero. Most of the time it works, but in a couple of cases I'm getting weird numbers. One answer Fortran gave me…
naomig
  • 271
  • 1
  • 7
  • 12
-3
votes
1 answer

Working with extra large numbers in C++ only using standard library (without boost Multiprecision or gmp)

I have a task to work with extra large numbers on our scientific project. Numbers are between 150 and 200 digits. How can I accomplish this only using the standard template library? I am ok on lower values using long double. I read somewhere that…
Larry Mack
  • 21
  • 1
-3
votes
2 answers

b%a where b is very large

We are given two integers a and b, a <= 100000, b < 10^250. I want to calculate b%a. I found this algorithm but can't figure out how it works. int mod(int a, char b[]) { int r = 0; int i; for(i=0;b[i];++i) { r=10*r +(b[i] -…
daft300punk
  • 169
  • 3
  • 16
-3
votes
3 answers

Finding sum of a series

In one of the problem(no.6) in the projectEuler.net website we have to find difference of square of the summation of n numbers and summation of squared numbers.It is very easy but I am not able to think that how to find this when the input is very…
Prerak
  • 57
  • 1
  • 7
-4
votes
2 answers

I am getting the error "Overflow." in Visual Basic 2010

Dim clicks As Integer clicks = 0 If clicks >= 10000000000000000000 Then a19.ForeColor = Color.FromArgb(0, 153, 0) End If 10000000000000000000 and above gives the error. Is there any way to have unlimited large length numbers?
Select Gamer
  • 11
  • 1
  • 10
-4
votes
2 answers

My algorithm is correct, but some results are wrong? (C++)

So I took this practice lesson called 'permMissingElement' on www.codility.com, and here is my code: #include using namespace std; int solution(vector &A) { int N = A.size(); double Nf = double(N); int n; double…
TheGrapeBeyond
  • 543
  • 2
  • 8
  • 19
-5
votes
1 answer

Large mathematical operation c++

I want large mathematical operation in c++. long long h= 4294967295; long long d=7910266469; long long n=10021211227; long long result; I am need calculate this is: h^d mod n result=pow(h,d) % n; I dont know which type using.Please help me for…
-5
votes
4 answers

Int64 arithmetic error

Why is the output "0 and 0"? How do I fix it? Int64 small= (long)0.25 * (long)Int64.MaxValue; Int64 large = (long)0.75 * (long)Int64.MaxValue; System.Console.WriteLine(small + " and " + large); System.Console.ReadLine(); //output //0 and…
sammarcow
  • 2,736
  • 2
  • 28
  • 56
-6
votes
2 answers

Summing the digits of a very large number

I want to sum the digits of the first 100.000 digits of pie (I have text with the numbers), but I want to do it in a specific form. I want to put the digits in a matrix (or whatever is convenient as a placeholder) with a small number of cells…
papajo
  • 167
  • 1
  • 8
1 2 3
30
31