[erlang-patches] [patch] binary to/from integer

Björn-Egil Dahlberg <>
Fri Jan 11 14:51:57 CET 2013

On 2013-01-11 13:09, Robert Virding wrote:
> I missed the beginning of this discussion but is it supposed to do
> list_to_binary(integer_to_list(I))?
> If so I fail to see a pressing need.
Let me educate you. =) We are mainly talking about 

In this time of web-services we frequently do encoding and decoding on 
text-based protocols.
It is preferable that these encode and decode transformations are fast.

Since we migrated from mainly having text as list to mostly binaries we 
are lacking a solid and fast binary to integer function. (In addition, 
it always seems stupid that I have to do: "b2i(I) -> 

It has never been a pressing need. It still isn't. It is more in the 
"would be nice to have" category.

Yet another way to go would be to have:


Just fire and forget.

and ofc (!)


The two latter function would naturally produce iodata in an arbitrary 
fashion but satisfying the textual iodata representation of the float or 
integer we used as input.

for convenience we should also have



// Björn-Egil

> Robert
> ----- Original Message -----
>> From: "Anthony Ramine" <>
>> To: "Bob Ippolito" <>
>> Cc: "erlang patches" <>
>> Sent: Friday, 11 January, 2013 11:42:45 AM
>> Subject: Re: [erlang-patches] [patch] binary to/from integer
>> I disagree. Making it the big endian encoding of that integer is
>> something
>> that is already covered by OTP (binary:encode_unsigned/1 and its
>> friends),
>> and as you say, it's a *encoding* operation, not a type conversion.
>> Naming
>> this new BIF "integer_to_binary" isn't more confusing than
>> "atom_to_binary".
>> --
>> Anthony Ramine
>> Le 10 janv. 2013 à 23:13, Bob Ippolito a écrit :
>>> The purpose of integer_to_binary still isn't totally obvious from
>>> the name or output type, maybe it's digits, maybe it's the big
>>> endian encoding of that integer (which is closer to the behavior
>>> of binary_to_term / term_to_binary). For the more seasoned Erlang
>>> developer, I think they would expect it to behave like
>>> integer_to_string, but what about newer users?
>> _______________________________________________
>> erlang-patches mailing list
>> http://erlang.org/mailman/listinfo/erlang-patches
> _______________________________________________
> erlang-patches mailing list
> http://erlang.org/mailman/listinfo/erlang-patches

More information about the erlang-patches mailing list