Re: integer_to_binary/2 returns incorrect values or crashes with bases other than 10
Fredrik <[email protected]>
| Newsgroups | gmane.comp.lang.erlang.patches |
|---|---|
| Message-ID | <[email protected]> |
On 09/09/2013 07:38 PM, Juan Jose Comellas wrote: > Sorry, there was a mistake in the commit message for the fix I had > previously sent. I've canceled the original pull request and created a > new one. The correct branch is in: > > git fetch git://github.com/jcomellas/otp.git > <http://github.com/jcomellas/otp.git> jc-integer-to-binary2_1 > > https://github.com/jcomellas/otp/compare/erlang:maint...jc-integer-to-binary2_1 > https://github.com/jcomellas/otp/compare/erlang:maint...jc-integer-to-binary2_1.patch > > > On Mon, Sep 9, 2013 at 2:23 PM, Juan Jose Comellas > <[email protected] <mailto:[email protected]>> wrote: > > The integer_to_binary/2 function works perfectly with base 10 > (because it just calls integer_to_binary/1), but when used with > other bases it fails when 0 or a negative number are passed as the > number to convert. e.g.: > > 1> integer_to_binary(0, 16). > <<>> > > 2> integer_to_binary(-1, 16). > ** exception error: bad argument > in function byte_size/1 > called as byte_size([]) > in call from erlang:integer_to_binary/3 > in call from integer_to_binary/2 > > The expected results are: > > 1> integer_to_binary(0, 16). > <<"0">> > > 2> integer_to_binary(-1, 16). > <<"-1">> > > I've sent this change as a pull request, but on this branch > there's the patch to fix this problem and some tests to cover > these cases. > > git fetch git://github.com/jcomellas/otp.git > <http://github.com/jcomellas/otp.git> jc-integer_to_binary2 > > https://github.com/jcomellas/otp/compare/erlang:maint...jc-integer_to_binary2 > https://github.com/jcomellas/otp/compare/erlang:maint...jc-integer_to_binary2.patch > > > > > _______________________________________________ > erlang-patches mailing list > [email protected] > http://erlang.org/mailman/listinfo/erlang-patches Hello, The patch will be running in the nightly builds and tests. Thanks for contributing, -- BR Fredrik Gustafsson Erlang OTP Team _______________________________________________ erlang-patches mailing list [email protected] http://erlang.org/mailman/listinfo/erlang-patches