diff options
author | Fredrik Gustafsson <[email protected]> | 2013-09-11 12:01:44 +0200 |
---|---|---|
committer | Fredrik Gustafsson <[email protected]> | 2013-09-11 12:01:44 +0200 |
commit | bb73eb3cbf6d7754389ffbe7e0bfe91fab865888 (patch) | |
tree | 4640727accd0f6b7956e5473e2cf8b37d8544fa0 /erts/preloaded/src | |
parent | de29dde83bc3aa6328e3db6876ddf929a5141e75 (diff) | |
parent | b6af3b245383767a6ab92a38b7a27732cce3d2bf (diff) | |
download | otp-bb73eb3cbf6d7754389ffbe7e0bfe91fab865888.tar.gz otp-bb73eb3cbf6d7754389ffbe7e0bfe91fab865888.tar.bz2 otp-bb73eb3cbf6d7754389ffbe7e0bfe91fab865888.zip |
Merge branch 'jcomellas/jc-integer-to-binary2/OTP-11311' into maint
* jcomellas/jc-integer-to-binary2/OTP-11311:
Update preloaded
Fix incorrect values returned by integer_to_binary/2
Diffstat (limited to 'erts/preloaded/src')
-rw-r--r-- | erts/preloaded/src/erlang.erl | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/erts/preloaded/src/erlang.erl b/erts/preloaded/src/erlang.erl index e016a50c4c..a969ef91dc 100644 --- a/erts/preloaded/src/erlang.erl +++ b/erts/preloaded/src/erlang.erl @@ -2891,22 +2891,23 @@ integer_to_binary(I, Base) when erlang:is_integer(I), erlang:is_integer(Base), Base >= 2, Base =< 1+$Z-$A+10 -> if I < 0 -> - <<"$-",(integer_to_binary(-I, Base, []))/binary>>; + <<$-,(integer_to_binary(-I, Base, <<>>))/binary>>; true -> integer_to_binary(I, Base, <<>>) end; integer_to_binary(I, Base) -> erlang:error(badarg, [I, Base]). -integer_to_binary(0, _Base, R0) -> - R0; integer_to_binary(I0, Base, R0) -> D = I0 rem Base, I1 = I0 div Base, - if D >= 10 -> - integer_to_binary(I1,Base,<<(D-10+$A),R0/binary>>); - true -> - integer_to_binary(I1,Base,<<(D+$0),R0/binary>>) + R1 = if + D >= 10 -> <<(D-10+$A),R0/binary>>; + true -> <<(D+$0),R0/binary>> + end, + if + I1 =:= 0 -> R1; + true -> integer_to_binary(I1, Base, R1) end. %% erlang:flush_monitor_message/2 is for internal use only! |