Skip to content

Commit

Permalink
Use Float.{to_string/1, to_charlist/1} when possible (#13898)
Browse files Browse the repository at this point in the history
  • Loading branch information
MikaelFangel authored Oct 13, 2024
1 parent ed75e60 commit e8821d1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/elixir/lib/inspect.ex
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ defimpl Inspect, for: Float do
if abs >= 1.0 and abs < 1.0e16 and trunc(float) == float do
[Integer.to_string(trunc(float)), ?., ?0]
else
:erlang.float_to_list(float, [:short])
Float.to_charlist(float)
end

color(IO.iodata_to_binary(formatted), :number, opts)
Expand Down
2 changes: 1 addition & 1 deletion lib/elixir/lib/list/chars.ex
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ end

defimpl List.Chars, for: Float do
def to_charlist(term) do
:erlang.float_to_list(term, [:short])
Float.to_charlist(term)
end
end
2 changes: 1 addition & 1 deletion lib/elixir/lib/string/chars.ex
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ end

defimpl String.Chars, for: Float do
def to_string(term) do
:erlang.float_to_binary(term, [:short])
Float.to_string(term)
end
end

0 comments on commit e8821d1

Please sign in to comment.