Is there a size limit for Erlang integers?
Asked Answered
S

2

13

I know that Erlang has arbitrary size integers, but is there a max limit on one of the standard implementations? If so, what?

Selfdeception answered 1/9, 2016 at 10:4 Comment(0)
O
12

Erlang uses bignum arithmetic, and Integers in Erlang are limited by available memory on the machine. Virtually, there is no limit on how large an Integer can be in Erlang. Take a look on this document: http://erlang.org/doc/efficiency_guide/advanced.html It has more detailed explanations regarding limits.

Oran answered 1/9, 2016 at 10:27 Comment(2)
It seems like the limit is the VM memory, which is 536,870,911 bytes (537MB) on a 32bit system and 2,305,843,009,213,693,951 bytes (2.3EB) on a 64bit system. Since we can store data in the first 28 or 60 bits of a 32 or 64bit field, we should be able to store integers up to roughly 2^2^63.9 or 10^10^18.7, given 2.3EB of RAM on a 64bit machine, or 10^10^9, given half a gigabyte of ram on a 32bit machine.Selfdeception
I love that bignum is used, but thanks to tagging, small enough integers only take 1 word (no memory overhead).Gordan
P
0

On 32-bit architectures: -134217729 < i < 134217728 (28 bits).

On 64-bit architectures: -576460752303423489 < i < 576460752303423488 (60 bits).

Pyrites answered 8/9, 2016 at 23:8 Comment(1)
Those are the limits for small integers. I was asking about the big integers of arbitrary size.Selfdeception

© 2022 - 2024 — McMap. All rights reserved.