[erlang-questions] undefined function erlang:binary_to_float/1

Erik Søe Sørensen eriksoe@REDACTED
Thu Jul 18 13:34:59 CEST 2013


I don't know what you mean by "the binary I receive is of the form {int,
int}", but decoding binaries directly is done using the bitstring syntax:

5> Data = <<123,0,0,0,205,204,204,62>>.
6> <<A:32/little, B:32/float-little>> = Data.  % In case the numbers are
encoded in little-endian.
7> A.
123
8> B.
0.4000000059604645



2013/7/18 Schneider <js@REDACTED>

> yea, this should work. But It's looks like my Problem is a little bit more
> complicated:
>
> I have a C client sending some Data via UDP. And I want to write a Erlang
> program receiving this data.
>
> the Data is of the form {unsigned long, float} (both stored as 4Byte
> values) but the binary I receive is of the form {int, int}.
> How can i convert the second one to an erlang float?
>
> bg,
> Johannes
>
>
> On Wed 17 Jul 2013 04:30:45 PM CEST, Wes James wrote:
>
>> Alternative for now??
>>
>> list_to_float(binary:bin_to_**list(<<"10.0">>)).
>> 10.0
>>
>>
>> On Wed, Jul 17, 2013 at 8:02 AM, Schneider <js@REDACTED
>> <mailto:js@REDACTED>> wrote:
>>
>>     Hi List,
>>
>>     I cannot find the function binary_to_float/1.
>>
>>     using Erlang R14B04 (erts-5.8.5) on ubuntu precise.
>>     What do I miss?
>>
>>     bg,
>>     Johannes
>>
>>     --
>>     GLOBE Development GmbH
>>     Königsberger Strasse 260
>>     48157 MünsterGLOBE Development GmbH
>>     Königsberger Strasse 260
>>     48157 Münster
>>     0251/5205 390
>>
>>     ______________________________**___________________
>>     erlang-questions mailing list
>>     erlang-questions@REDACTED <mailto:erlang-questions@**erlang.org<erlang-questions@REDACTED>
>> >
>>     http://erlang.org/mailman/__**listinfo/erlang-questions<http://erlang.org/mailman/__listinfo/erlang-questions>
>>     <http://erlang.org/mailman/**listinfo/erlang-questions<http://erlang.org/mailman/listinfo/erlang-questions>
>> >
>>
>>
>>
>
>
> --
> GLOBE Development GmbH
> Königsberger Strasse 260
> 48157 MünsterGLOBE Development GmbH
> Königsberger Strasse 260
> 48157 Münster
> 0251/5205 390
> ______________________________**_________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/**listinfo/erlang-questions<http://erlang.org/mailman/listinfo/erlang-questions>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130718/768147a5/attachment.htm>


More information about the erlang-questions mailing list