[erlang-questions] Fibonacci with escript (more fun...) [with CRASH]

Laurent Picouleau laurent@REDACTED
Fri Apr 13 22:44:16 CEST 2007


Hi,

Le ven 13/04/2007 à 18:15, Roger Larsson a écrit :
> Found this
> 
> http://www.math.utah.edu/~beebe/software/java/fibonacci/
> 
> so I thought - what about Erlang? My attempt in escript is attached
> # chmod +x fibmini.erl
> this runs well for a lot higher inputs than most other languages
> # ./fibmini.erl 100
> and even
> # ./fibmini.erl 1000
> produces some output (you need to modify format)
> 
> But
> # ./fibmini.erl 2000
> ends with
> "- - -
> 1475 ******************************    1.61803398874989    
> 0.000000000000000000
> escript: script failed with error reason badarith
> "
> Why?

Because f(1476) is bigger than 1.797e+308 which is the maximum value for
a float. So Hi/Lo can't be computed because Hi can't be cast to a float.

Regards,

-- 
Laurent Picouleau <laurent@REDACTED>
Erlang Training and Consulting




More information about the erlang-questions mailing list