[erlang-questions] term_to_binary and message passing

Tony Rogvall tony@REDACTED
Thu Dec 28 15:33:41 CET 2006


On 28 dec 2006, at 14.52, Joel Reymont wrote:

> junior:~ joelr$ erl
> Erlang (BEAM) emulator version 5.5 [source] [async-threads:0] [hipe]
>
> Eshell V5.5  (abort with ^G)
> 1> size(term_to_binary(0.2)).
> 33
>
> Does this mean that any float I send within the VM will result in a
> 33-byte message?
>
If you look in sys_float.c (under erts/emulator/sys/unix ) you will  
find the function sys_double_to_chars.
Why this encoding is used instead of IEEE float encoding is a  
"historical" issue, that been argued about now
and then ;-)  My opinion is that it's an over kill, but who use  
floating point any way :-)

sprintf(buf, "%.20e", fp);

The code even covers locale differences translating , into . ..


I wish you all a happy new year !

/Tony

> 	Thanks, Joel
>
> --
> http://wagerlabs.com/
>
>
>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list