We discussed this in the past and we decided to only parse floats supported by the language itself. Luckily this case is easy to address within your own projects by checking if the string starts with a dot and then adding a leading 0.
In any case, thanks for asking and have a good weekend! On Fri, Oct 2, 2020 at 1:18 PM Alessandro Di Maria <[email protected]> wrote: > > Hello > > I would like to open a PullRequest that would allow parsing floats with a > leading dot. > > Current situation: > > iex> Float.parse(".25") > :error > > Suggested: > > iex> Float.parse(".25) > {0.25, ""} > > I detected this behavior in a form that uses LiveView. The form has an > input field for a float, on change a new calculation is triggered. > When a user now wants to changes the value from "8.0" to "9.0" he may > delete first the "8", leaving the field with ".0". This blew up my LiveView. > > I forked the repo, and made the changes already, all tests are passing so > far. > > Alessandro > > -- > You received this message because you are subscribed to the Google Groups > "elixir-lang-core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elixir-lang-core/c1944f60-18d4-4317-90d7-c43bcd2024een%40googlegroups.com > <https://groups.google.com/d/msgid/elixir-lang-core/c1944f60-18d4-4317-90d7-c43bcd2024een%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4Kwe85GwEtp87QDKsJMtr7W%3Dtko-9pr%2BOzEtRumeC1qDA%40mail.gmail.com.
