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

Extremely Large Integers in PHP

Possible Duplicate: Working with large numbers in PHP. I run a completely useless Facebook app. I'm having a problem with PHP's support for integers. Basically, users give themselves ridiculous numbers of points. The current "king" has…
Tyler Menezes
  • 633
  • 1
  • 4
  • 17
10
votes
3 answers

Which data type to use for a very large numbers in C++?

I have to store the number 600851475143 in my program. I tried to store it in long long int variable and long double as well but on compiling it shows the error integer constant is too large for "long" type. I have also tried unsigned long long…
Vaibhav
  • 6,620
  • 11
  • 47
  • 72
10
votes
1 answer

What technical limitations prevent the calculation of Graham's number in python?

Assuming that the computer running this program has an infinite amount of memory, I'm interested in where Python will break when running the following: For fun, I implemented hyperoperators in python as the module hyperop. One of my examples is…
Hooked
  • 84,485
  • 43
  • 192
  • 261
10
votes
3 answers

Karatsuba Multiplication for unequal size, non-power-of-2 operands

What's the most efficient way to implement Karatsuba large number multiplication with input operands of unequal size and whose size is not a power of 2 and perhaps not even an even number? Padding the operands means additional memory, and I want to…
The_Sympathizer
  • 1,191
  • 9
  • 17
9
votes
6 answers

convert astronomically large numbers into human readable form in C/C++

My program prints out HUGE numbers - like 100363443, up to a trillion -- and it sort of hard to read them, so I would like to print any number in easy to read form. right now I use printf ("%10ld", number); format I would appreciate a resulting…
vehomzzz
  • 42,832
  • 72
  • 186
  • 216
9
votes
2 answers

Javascript: toString(36) for large integers

15955067621307336078.toString(36); returns '3d7vzfy5k2as8' in Javascript because the large integer cannot be represented (the correct answer is '3d7vzfy5k29ou'). Does someone have a clever function that takes a large integer as a string and…
Meekohi
  • 10,390
  • 6
  • 49
  • 58
8
votes
3 answers

square root of a number greater than 10^2000 in Python 3

I'd like to calculate the square root of a number bigger than 10^2000 in Python. If I treat this number like a normal integer, I will always get this result back: Traceback (most recent call last): File "...", line 3, in print(…
cubeAD
  • 83
  • 1
  • 1
  • 5
8
votes
3 answers

How to generate random numbers in a very large range via javascript?

I was using this function for a long time and was happy with it. You probably saw it millions of times. It is even in the example section of the MDN documentation for Math.random()! function random(min, max) { return Math.floor(Math.random() *…
anonymous
  • 1,522
  • 14
  • 24
8
votes
2 answers

Handling numbers larger than Long in VBA

I am Currently trying to write some code in VBA to solve a problem from Project Euler. I have been trying to answer a question that requires you to find primes that can be divided into a number that will not fit in a long. Any suggestions as how…
Agent389
  • 81
  • 1
  • 1
  • 6
7
votes
3 answers

Multiplication of large integers

I tried to multiply 111111111*111111111, which is the same as 111111111^2, and got incorrect results. It should give 12345678987654321, but instead it gives a rounding error. Do I need to use some special variable type for long numbers or is this a…
Puzzzled
7
votes
4 answers

Types for large numbers

I am working on an app that will need to handle very large numbers. I checked out a few available LargeNumber classes and have found a few that I am happy with. I have a class for large integers and for large floating point numbers. Since some of…
Sruly
  • 10,200
  • 6
  • 34
  • 39
7
votes
2 answers

A haskell floating point calculation anomaly?

2022 Update: This bug was filed as a GHC ticket and is now fixed: https://gitlab.haskell.org/ghc/ghc/issues/17231 so this is no longer an issue. Using ghci 8.6.5 I want to calculate the square root of an Integer input, then round it to the bottom…
7
votes
1 answer

Exponential calculation in Python

While experimenting with Euler 99, I noticed that these operations take different time: >>> 632382**518061 # never finishes.. >>> 632382**518061 > 519432**525806 # finishes in few seconds True I wonder what's the reason for this?
Eugene Yarmash
  • 142,882
  • 41
  • 325
  • 378
7
votes
2 answers

warning c4307 integral constant overflow in C

I have this operation (8 * (512 * 786432)) and the product is 3221225472 I tried to use it with variables like longlong, unsigned long But the compiler throw me an error c4307 integral constant overflow and I need the result for use it with…
Makuvex Linux
  • 91
  • 1
  • 2
  • 6
7
votes
12 answers

Find factorial of large numbers in Java

I tried to find the factorial of a large number e.g. 8785856 in a typical way using for-loop and double data type. But it is displaying infinity as the result, may be because it is exceeding its limit. So please guide me the way to find the…
Himanshu Aggarwal
  • 1,803
  • 2
  • 24
  • 36
1
2
3
30 31