[erlang-questions] convert strings like "1e-8" to floats.

Richard A. O'Keefe <>
Thu Feb 9 05:23:14 CET 2017



On 9/02/17 12:16 AM, Mikael Pettersson wrote:
> Write your own conversion routine.
>
> Your mistake is assuming literals like floats have the same look and feel
> regardless of language or environment.  That's in general not true.

This is spot on, but I suggest *transliteration* from the target syntax
to Erlang literal syntax followed by using list_to_float/1 to do the
actual *conversion*.  Transliterating from one syntax to another is
just straightforward text processing, e.g., turn ".2D7" into "0.2e7".
Converting *accurately* is somewhere past "difficult" and well into
"arcane".





More information about the erlang-questions mailing list