-2

I have also seen other programming language by Python have a very huge integer range , even Java don't have , how ? How it's made possible?

3
  • 2
    In Java you have a BigInteger... Commented Mar 11, 2017 at 20:59
  • consider: instead of a block of memory stating the number, a block of memory stating how many digits the number has then the space for those digits be dynamically allocated. Basically if python runs out of room to store a number it literally adds more space. Commented Mar 11, 2017 at 21:08
  • The majority of languages have an arbitrary sized integer type built into the language, including Java. en.wikipedia.org/wiki/… Commented Mar 11, 2017 at 21:17

1 Answer 1

0

Most programming languages offer integers based on the underlying CPU's machine word length, using single CPU instructions for e.g. add, in the interest of speed. It's always possible to provide a longer integer size by using multiple words and the carry/overflow flags in the hardware, but it's slower to do so and uses more memory.

This is very similar to how you do math on paper when you're given operands which are too big for you to multiply in your head.

Python prioritizes programmer convenience over raw speed, so it simply makes its integers as big as they need to be, on-demand.

Sign up to request clarification or add additional context in comments.

2 Comments

What are the biggest numbers that you, personally, can add on a sheet of paper?
Well I can use order of precedence to add numbers till near infinity

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.