[erlang-questions] what does when do here? fib(1200000) so slow, erlang cant handle big numbers?

Jesper Louis Andersen jesper.louis.andersen@REDACTED
Tue Jul 1 16:06:55 CEST 2008


2008/7/1 Edwin Fine <erlang-questions_efine@REDACTED>:

>The N > 0 prevents infinite recursion if you call fib(-1).

It is much more powerful than that, as it also fails calls like fib(0.5) though
it does so after a considerable amount of time. One could imagine moving
the guard to the fib/1 call rather than having it on fib_i/3 with the
possibility
that the VM has to check it each time (I don't know what the VM does here,
specifically). A check on is_integer/1 could eliminate the wait time as well.



More information about the erlang-questions mailing list