Help with bit pattern
Fri Aug 25 00:30:22 CEST 2006
On 8/24/06, Ulf Wiger <ulf@REDACTED> wrote:
> Den 2006-08-24 19:47:44 skrev Bob Ippolito <bob@REDACTED>:
> > I see you're reading a SWF header... The padding size should be (8 -
> > ((5 + NBits1 * 4) rem 8)). I don't think that bit syntax is going to
> > work directly anyway because IIRC SWF files store bits in MSB first
> > order(!) for variable bit length fields.
> You can specify endianness in bit syntax patterns. Or did you mean
> something else?
> From the reference manual, on the Endianness type specifier:
> "Endianness = big | little | native
> Native-endian means that the endian will be resolved at load time to be
> either big-endian or little-endian, depending on what is native for the
> CPU that the Erlang machine is run on. The default is big."
You're right, I was thinking of a different part of the SWF format
that's rather nuts:
<<TagCodeAndLength:16/little, _/binary>> = Data,
<<TagCode:10, Length:6>> = <<TagCodeAndLength:16>>.
There's also a float encoding in the SWF format that looks like this:
<<Left:32, Right:32>> = <<Float:64/float-little>>,
(I wish I was kidding)
More information about the erlang-questions