[erlang-questions] floating point syntax

黃耀賢 (Yau-Hsien Huang) g9414002.pccu.edu.tw@REDACTED
Thu Apr 15 18:07:25 CEST 2010


On Thu, Apr 15, 2010 at 10:21 PM, Anthony Shipman <als@REDACTED> wrote:

> The reference manual says "There are two types of numeric literals,
> integers
> and floats. Besides the conventional notation,..."
>
> But what is the "conventional notation" exactly? I find that this fails:
> 19> io_lib:fread("~f", "1e+2").
> {error,{fread,float}}
>
> Also
> 1.e+2 fails
> 1     fails
> 1.    fails
> 1.0   succeeds
> .1    fails
> 0.1   succeeds
> 1.0e+2 succeeds
>
> Is it supposed to be like that or is there a bug?


In human sense, do you think 1, (1.), and (.1) floating point numbers?

Keep things from C or Java out, and you will be satisfied.


More information about the erlang-questions mailing list