Re: creating a binary number

"Richard O'Keefe" <[email protected]>
Newsgroups gmane.comp.lang.erlang.general
Message-ID <CABcYAd+SN8C=hFSyY8u7O-pdVLKE0-QA-0Zw8etN=cXNe77K-w@mail.gmail.com>
What do you mean by "a binary number"?
Integers are just integers.  How they are represented
internally is none of our business; how they are
represented externally is up to you.

2#0
2#1
2#10
2#11
2#100
2#101
2#110
2#111

I'm sure you get the picture.

list_to_integer("1000", 2)
list_to_integer("1001", 2)
list_to_integer("1010", 2)
list_to_integer("1011", 2)

I'm sure you get that picture too.

In your example
<<1:1/bitstring, ...
I see two integers but I do not see a bit string.
<<1:1, 1:1, 0:1, 0:1>>
<<1:1, 1:1, 0:1, 1:1>>
<<1:1, 1:1, 1:1, 0:1>>
<<1:1, 1:1, 1:1, 1:1>>

but that cannot be what you want because you asked
about making binary numbers, and the binaries you get
are not numbers.


On Fri, 10 Dec 2021 at 05:05, Java House <[email protected]> wrote:

> Hello
>
> I am trying to build a binary number but I cannot find the correct way:
> 13> <<1:1/bitstring,
> 0:1/bitstring,0:1/bitstring,0:1/bitstring,0:1/bitstring,0:1/bitstring,0:1/bitstring,0:1/bitstring>>.
> ** exception error: bad argument
>      in function  eval_bits:eval_exp_field1/6 (eval_bits.erl, line 123)
>      in call from eval_bits:create_binary/2 (eval_bits.erl, line 81)
>      in call from eval_bits:expr_grp/4 (eval_bits.erl, line 72)
>
> How do we build a binary number e.g.
> 10000000 or 10101010 or even a binary number that is not just 8 bit but
> 12, 14 or 17 bit long
>
> Kind Regards
> Nikolas
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.