|
|
@ -65,7 +65,17 @@ defmodule BlockScoutWeb.CurrencyHelpers do |
|
|
|
|
|
|
|
|
|
|
|
iex> format_according_to_decimals(Decimal.new(205000), 2) |
|
|
|
iex> format_according_to_decimals(Decimal.new(205000), 2) |
|
|
|
"2,050" |
|
|
|
"2,050" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
iex> format_according_to_decimals(205000, 2) |
|
|
|
|
|
|
|
"2,050" |
|
|
|
""" |
|
|
|
""" |
|
|
|
|
|
|
|
@spec format_according_to_decimals(non_neg_integer(), non_neg_integer()) :: String.t() |
|
|
|
|
|
|
|
def format_according_to_decimals(value, decimals) when is_integer(value) do |
|
|
|
|
|
|
|
value |
|
|
|
|
|
|
|
|> Decimal.new() |
|
|
|
|
|
|
|
|> format_according_to_decimals(decimals) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
@spec format_according_to_decimals(Decimal.t(), non_neg_integer()) :: String.t() |
|
|
|
@spec format_according_to_decimals(Decimal.t(), non_neg_integer()) :: String.t() |
|
|
|
def format_according_to_decimals(%Decimal{sign: sign, coef: coef, exp: exp}, decimals) do |
|
|
|
def format_according_to_decimals(%Decimal{sign: sign, coef: coef, exp: exp}, decimals) do |
|
|
|
sign |
|
|
|
sign |
|
|
|