fix
This commit is contained in:
parent
394ebe67cc
commit
c899626954
@ -10,7 +10,7 @@
|
|||||||
-author("licheng5").
|
-author("licheng5").
|
||||||
|
|
||||||
%% API
|
%% API
|
||||||
-export([timestamp/0, number_format/2, current_time/0, timestamp_of_seconds/0, float_to_binary/2]).
|
-export([timestamp/0, number_format/2, current_time/0, timestamp_of_seconds/0, float_to_binary/2, int_format/2]).
|
||||||
-export([step/3, chunks/2, rand_bytes/1, uuid/0, md5/1, parse_mapper/1]).
|
-export([step/3, chunks/2, rand_bytes/1, uuid/0, md5/1, parse_mapper/1]).
|
||||||
-export([json_data/1, json_error/2]).
|
-export([json_data/1, json_error/2]).
|
||||||
-export([queue_limited_in/3, assert_call/2]).
|
-export([queue_limited_in/3, assert_call/2]).
|
||||||
@ -33,6 +33,15 @@ number_format(Num, _Decimals) when is_integer(Num) ->
|
|||||||
number_format(Float, Decimals) when is_float(Float) ->
|
number_format(Float, Decimals) when is_float(Float) ->
|
||||||
list_to_float(float_to_list(Float, [{decimals, Decimals}, compact])).
|
list_to_float(float_to_list(Float, [{decimals, Decimals}, compact])).
|
||||||
|
|
||||||
|
int_format(Num, Len) when is_integer(Num), Len > 0 ->
|
||||||
|
S = integer_to_list(Num),
|
||||||
|
case length(S) > Len of
|
||||||
|
true ->
|
||||||
|
list_to_integer(lists:sublist(S, 1, Len));
|
||||||
|
false ->
|
||||||
|
Num
|
||||||
|
end.
|
||||||
|
|
||||||
step(Start, End, Step) when is_integer(Start), is_integer(End), is_integer(Step), Start < End, Step > 0 ->
|
step(Start, End, Step) when is_integer(Start), is_integer(End), is_integer(Step), Start < End, Step > 0 ->
|
||||||
step(Start, End, Step, []).
|
step(Start, End, Step, []).
|
||||||
step(Start, End, Step, Acc) when Start < End ->
|
step(Start, End, Step, Acc) when Start < End ->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user