11

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

Filip Haglund
  • 13,919
  • 13
  • 64
  • 113

2 Answers2

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.

fycth
  • 3,410
  • 25
  • 37
  • 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. – Filip Haglund Sep 14 '16 at 08:39
  • I love that bignum is used, but thanks to tagging, small enough integers only take 1 word (no memory overhead). – YvesgereY Feb 17 '21 at 16:22
0

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

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

ghnome
  • 57
  • 1
  • 7