[erlang-questions] float_to_binary?
Zvi
exta7@REDACTED
Tue Jan 27 14:22:01 CET 2009
there is no erlang:float_to_binary ...
1> Pi = math:pi().
3.141592653589793
2> <<Pi:64/float>>.
<<64,9,33,251,84,68,45,24>>
so
to_binary(X) when is_integer(X) -> <<X>>;
to_binary(X) when is_float(X) -> <<X:64/float>>.
Zvi
Steve Davis-5 wrote:
>
> I'm probably being dumb, but I am stuck...
>
> to_binary(X) when is_integer(X) -> <<X>>;
> to_binary(X) when is_float(X) -> ??.
>
> ...btw attempting to use erlang:float_to_binary(X, 64) turned out to be
> a very bad idea (computer just went POP!).
>
> Thanks for any assistance!
> /s
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
>
--
View this message in context: http://www.nabble.com/float_to_binary--tp21684748p21685174.html
Sent from the Erlang Questions mailing list archive at Nabble.com.
More information about the erlang-questions
mailing list