list_to_float

Dmitriy Kargapolov <>
Wed Aug 9 22:03:22 CEST 2006


I was just trying to say that I don't see any reason for such limitation 
when we're converting from string to float.

James Hague wrote:
>> The current implementation is limited to string only argument - this is 
>> reasonable, but it's not clear why implementation is limited to narrow 
>> X.X representation? Couldn't float be expressed as "0"?
> 
> "0" in Erlang means "integer zero."  You need to specify "0.0" for a float.
Depends on context. If you are talking about term syntax (as in an 
example below) yes, I agree. If we're considering external text that 
should be interpreted (during the IO operations) as an integer or float, 
no, I do not agree that there is any reason to limit text representation 
when we know what we want to have as the result of conversion.

> Try these in the shell:
> 
> is_integer(0 + 1).    % gives true
> is_integer(0.0 + 1).  % gives false
> 
>> As to list_to_number idea, what type of result is expected? Depending on 
>> argument text representation?
>  
> Correct.  It's analogous to the is_number function, which checks if a value
> is either an integer or float.
> 



More information about the erlang-bugs mailing list