@@ -323,12 +323,13 @@ defmodule Integer do
323323 # Please reapply commit 2622fd6b0aa419a983a899a1fbdb5deefba3d85d.
324324 @ doc """
325325 Returns a binary which corresponds to the text representation
326- of `integer`.
326+ of `integer` in the given `base`.
327+
328+ `base` can be an integer between 2 and 36. If no `base` is given, it defaults to `10`.
327329
328330 Inlined by the compiler.
329331
330332 ## Examples
331-
332333 iex> Integer.to_string(123)
333334 "123"
334335
@@ -341,22 +342,6 @@ defmodule Integer do
341342 iex> Integer.to_string(0123)
342343 "123"
343344
344- """
345- @ spec to_string ( integer ) :: String . t ( )
346- def to_string ( integer ) do
347- :erlang . integer_to_binary ( integer )
348- end
349-
350- @ doc """
351- Returns a binary which corresponds to the text representation
352- of `integer` in the given `base`.
353-
354- `base` can be an integer between 2 and 36.
355-
356- Inlined by the compiler.
357-
358- ## Examples
359-
360345 iex> Integer.to_string(100, 16)
361346 "64"
362347
@@ -368,15 +353,17 @@ defmodule Integer do
368353
369354 """
370355 @ spec to_string ( integer , 2 .. 36 ) :: String . t ( )
371- def to_string ( integer , base ) do
356+ def to_string ( integer , base \\ 10 ) do
372357 :erlang . integer_to_binary ( integer , base )
373358 end
374359
375360 # TODO: Remove Integer.to_charlist/1 once the minimum supported version is
376361 # Erlang/OTP 22, since it is covered by the now BIF Integer.to_charlist/2.
377362 # Please reapply commit 2622fd6b0aa419a983a899a1fbdb5deefba3d85d.
378363 @ doc """
379- Returns a charlist which corresponds to the text representation of the given `integer`.
364+ Returns a charlist which corresponds to the text representation of `integer` in the given `base`.
365+
366+ `base` can be an integer between 2 and 36. If no `base` is given, it defaults to `10`.
380367
381368 Inlined by the compiler.
382369
@@ -394,21 +381,6 @@ defmodule Integer do
394381 iex> Integer.to_charlist(0123)
395382 '123'
396383
397- """
398- @ spec to_charlist ( integer ) :: charlist
399- def to_charlist ( integer ) do
400- :erlang . integer_to_list ( integer )
401- end
402-
403- @ doc """
404- Returns a charlist which corresponds to the text representation of `integer` in the given `base`.
405-
406- `base` can be an integer between 2 and 36.
407-
408- Inlined by the compiler.
409-
410- ## Examples
411-
412384 iex> Integer.to_charlist(100, 16)
413385 '64'
414386
@@ -420,7 +392,7 @@ defmodule Integer do
420392
421393 """
422394 @ spec to_charlist ( integer , 2 .. 36 ) :: charlist
423- def to_charlist ( integer , base ) do
395+ def to_charlist ( integer , base \\ 10 ) do
424396 :erlang . integer_to_list ( integer , base )
425397 end
426398
0 commit comments