[erlang-questions] Binaries
Bob Cowdery
bob@REDACTED
Thu Mar 3 23:04:21 CET 2011
On 03/03/2011 21:18, Adam Kocoloski wrote:
> On Mar 3, 2011, at 2:56 PM, Bob Cowdery wrote:
>
>> One of the things I need to do is move large binaries of up to 4096
>> floats around between processes. As there are real-time constraints on
>> processing this data I just wanted to check a few things.
>>
>> The docs say that large binaries are zero copy (presumable only in the
>> same node). How exactly does this work in a lock free environment?
>>
>> 1> T=[1.0].
>> [1.0]
>> 2> B=term_to_binary(T).
>> <<131,108,0,0,0,1,99,49,46,48,48,48,48,48,48,48,48,48,48,
>> 48,48,48,48,48,48,48,48,48,48,...>>
>> 3> size(B).
>> 39
>>
>> The docs also say that binary data is efficient. Why does 1 float
>> convert to 39 bytes? This ratio only reduces slightly with larger lists
>> . If erlang holds floats internally in 64 bit format I don't understand
>> why it needs 39 bytes.
>>
>> Bob
> Hi Bob, I think you're looking for the {minor_version, 1} option:
>
> http://erldocs.com/R14B01/erts/erlang.html?i=1&search=term_to#term_to_binary/2
>
> 1> byte_size(term_to_binary(1.0, [{minor_version, 1}])).
> 10
>
> Regards, Adam
> ______
Hi Adam
Thankyou, that's much more what I was expecting. The docs that install
are only the application groups and the Basic/binary has none of this
stuff in it. It seems one has to look in the ERTS manual. Rather
confusing unless familiar with the system.
Bob
> __________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>
More information about the erlang-questions
mailing list