[erlang-questions] Binary comprehension (was Re: double to float)

Zvi exta7@REDACTED
Fri Oct 19 18:22:52 CEST 2007


1> Bin = <<"hello">>.
<<hello>>
2> [B || <<B:8>> <= Bin].
** 1: binary generator in code not compiled with the binary comprehension
flag *

How do I enable binary comprehension?
Do I really need to recompile entire Erlang/OTP with this?
Or does it referes to the compile directive in the .erl source, something
like this?

-compile([binary_comprehension]).

or

c(mod.erl, [binary_comprehension]).

If yes, then how do I use it from the Erlang shell?

TIA,
Zvi








Matthew O'Gorman wrote:
> 
> this works great if you compile with binary_comprehension
> 
> List_of_floats = [Float || << Float/float >> <= Binary].
> 
> mog
> On 10/16/07, Sten Kvamme <sten@REDACTED> wrote:
>> Yes thanks, but I have the file in a binary variable and would like to do
>> something like this:
>>
>> {<<F/float>>,B} = split_binary(Thefile, 8),
>>
>> or maybe
>>
>> <<F:8/binary,B/binary>> = Thefile,
>> <<X/float>> =  F,
>>
>>
>> /Sten
>>
>>
>> On Oct 16, 2007, at 20:43 , Vlad Dumitrescu wrote:
>>
>>
>> <<X/float>> = <<184,162,71,68,75,65,104,64>>
>>
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://www.erlang.org/mailman/listinfo/erlang-questions
>>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
> 
> 

-- 
View this message in context: http://www.nabble.com/double-to-float-tf4635969.html#a13286617
Sent from the Erlang Questions mailing list archive at Nabble.com.




More information about the erlang-questions mailing list