[erlang-questions] floating point exception when accuracy exceeds limit

Sverker Eriksson sverker.eriksson@REDACTED
Tue Jan 20 12:09:00 CET 2015


Largest possible floating-point number with double precision is

1.7976931348623157e308

http://en.wikipedia.org/wiki/Double-precision_floating-point_format

/Sverker

On 01/20/2015 11:26 AM, Johan Montelius wrote:
>
> This might be no news to anyone who is doing a lot of floating point 
> arithmetics but it made me scratch my head.
>
>
> 7> (6.0e150*6.0e150).
> 3.6000000000000004e301
>
> 8> (6.0e154*6.0e154).
> ** exception error: an error occurred when evaluating an arithmetic 
> expression
>      in operator  */2
>         called as 6.0e154 * 6.0e154
>
>
> Hmm, would it not be better to answer with the highest possible accuracy?
>
>   Johan
>
>




More information about the erlang-questions mailing list