[erlang-questions] String representations of floating point numbers

Hugo Mills hugo@REDACTED
Fri Mar 15 23:52:09 CET 2019


   Where in the manual is the set of allowable string representations
of floating point numbers documented? I'd have expected it to be here:

http://erlang.org/doc/reference_manual/data_types.html

... but apparently not.

   Specifically, I'm trying to use list_to_float/1, and I've been
trying to reverse engineer it:

1> list_to_float("-1").
** exception error: bad argument
     in function  list_to_float/1
        called as list_to_float("-1")
2> list_to_float("-1.0").
-1.0
3> list_to_float("-1.0e-23").
-1.0e-23
4> list_to_float("-1e-23").  
** exception error: bad argument
     in function  list_to_float/1
        called as list_to_float("-1e-23")
5> list_to_float(".3").
** exception error: bad argument
     in function  list_to_float/1
        called as list_to_float(".3")

   An actual written specification would be really handy here. Even
just a regex or EBNF for them. I'm writing a parser for something
where the definition of floating point literals isn't quite the same
as Erlang's, and it's a bit painful.

   Hugo.

-- 
Hugo Mills             | Your problem is that you've got too much taste to be
hugo@REDACTED carfax.org.uk | a web developer.
http://carfax.org.uk/  |
PGP: E2AB1DE4          |                                          Steve Harris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20190315/49a3edfb/attachment.bin>


More information about the erlang-questions mailing list