[erlang-questions] Limits on integer size

Imre Palik <>
Tue Aug 26 08:56:20 CEST 2008


Hi,

I tried to generate some test data in the following way:

-module(test_gen).
-export([run/0]).

loop(0) ->
    void;
loop(I) ->
    HN = 999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999,
    io:format("~w ~w~n", [random:uniform(HN), random:uniform(HN)]),
    loop(I - 1).

run() -> loop(10).


But the result is this:

16> test_gen:run().
** exception error: bad argument in an arithmetic expression
     in function  random:uniform/1
     in call from test_gen:loop/1


But if I decrease the size of HN to let's say 100 digits, then it works without any problem.
Could somebody tell me the limitations that I have with integers in erlang?  Is it possible to tune these somehow (config file, environment variable, etc.)?

Thx.

ImRe

P.S.: I am running Erlag 5.6.3 on windows



More information about the erlang-questions mailing list