[erlang-bugs] float parsing bug

Robert Virding rvirding@REDACTED
Mon Jan 11 19:34:51 CET 2010


2010/1/10 Ulf Wiger <ulf.wiger@REDACTED>

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Alexander Borovsky wrote:
> >
> > 42.0 could have text representation "42".
> >
> > In most languages (C, Java, Ruby, etc) "42" parsed to float with no
> errors.
> >
> > Also in some cases float values could be outputted with no decimal point:
>
> This is why I wrote "arguably". :)
>
> The question has been up on the mailing list before:
>
> http://www.erlang.org/cgi-bin/ezmlm-cgi?4:msp:15372:bkelgefglpkakhbedlbf
> (May 12 2005)
> http://www.erlang.org/cgi-bin/ezmlm-cgi/4/27647 (Jul 3 2007)
> http://www.erlang.org/cgi-bin/ezmlm-cgi/4/37899 (Sep 4 2008)
>
> In the last one, Richard Carlsson wrote:
>
>  It's a "feature": list_to_float/1 is a rather low level function,
>  which assumes that you have already checked that the string has the
>  proper form for an Erlang float, i.e., "0.0" and "1.0E-3" are ok,
>  but "22", ".0", and "0." are not.
>
> But you're definitely not the first one to disagree with this design
> decision.
>

I *knew* it was a mistake to add floats in the first place. If NASA can hit
the moon without them why should we need them for a telephone exchange or
serving up a few pages on the web?

Robert


More information about the erlang-bugs mailing list