Bug ... in Erlang

Raimo Niskanen <>
Wed Jun 18 14:19:00 CEST 2003


These bug will be fixed in R9C:



There was bug with list_to_float/1 returning weird floats on some 
Linuxes and on (all) Windowses.

1> erlang:display(list_to_float("1.0e309")). % Linux
inf
true

1> erlang:display(list_to_float("1.0e309")). % Windows
1.#INF000e+000
true
2> list_to_float("1.0e309").
1.00000e+0

Here "inf" and "1.#INF000e+000" are infinity floats (that should not 
exist in Erlang). You can try to assign them to a variable and 
performing tests on them. For example list_to_float("1.0e309") > 1.0e308 
-> true. But printing with io:format/2 (as the shell does) crashes on 
Linux and prints 1.00000e+0 on Windows.

So, list_to_float/1 has been rewritten to use strtod() (previously 
atof() on Unixish systems and sscanf("%lf",..) on Windows) and check 
errors on all platforms. Hopefully no more malicious floats.



There was a problem when the shell crashed, which it seldom does. It did 
when printing infinity floats on Linux. You could type ^G to get to the 
job handler menu and there start a new shell, but not many knew that.

So, the shell handling has been rewritten to automatically start a new 
shell if it crashes.



For snapshot builders and for us internally there was a problem with the 
new erl_scan:

1> 1.0e309.
** 1: illegal float **
2> .
** 1: syntax error before: '.' **

The new scanner left unscanned data on the input stream after a scan 
error. Therefore the second '.' command.

So, the new erl_scan has been rewritten to always scan to full stop 
('.') while recording errors, and finally check if there were any.

Note that you can still do (as before):

1> a. b.
a
2> b.
b



/ Raimo Niskanen, Erlang/OTP, Ericsson AB



Joe Armstrong wrote:
> 
>  Try typing the following:
> 
> 	> 1.0e309.
> 
>  Is this a bug?
> 
>  /Joe
> 




More information about the erlang-questions mailing list