When I call Float.parse/1 with an exponent that is too large, Erlang raises an ArgumentError:
iex(1)> Float.parse("12.345e308")
** (ArgumentError) argument error
:erlang.binary_to_float("12.345e308")
(elixir) lib/float.ex:67: Float.parse_unsigned/4
The error isn't communicative, and the documentation for Float.parse/1 does not mention it. Based on the current documentation I would expect :error to be returned instead, for example:
joshuap@89b65af
~/code/elixir ‹float_exponent_fix› » bin/elixir lib/elixir/test/elixir/float_test.exs 18 ↵
...
1) test parse (FloatTest)
lib/elixir/test/elixir/float_test.exs:6
** (ArgumentError) argument error
stacktrace:
:erlang.binary_to_float("12.345e308")
(elixir) lib/float.ex:67: Float.parse_unsigned/4
lib/elixir/test/elixir/float_test.exs:35
..
Finished in 0.2 seconds (0.2s on load, 0.00s on tests)
6 tests, 1 failure
Would this be desired behavior to add, or is the exception expected?
When I call
Float.parse/1with an exponent that is too large, Erlang raises anArgumentError:The error isn't communicative, and the documentation for
Float.parse/1does not mention it. Based on the current documentation I would expect:errorto be returned instead, for example:joshuap@89b65af
Would this be desired behavior to add, or is the exception expected?