Equal binaries with different integers

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

Equal binaries with different integers

DOBRO
Hi,
could anyone explain me how is it possible?
 
In shell:
 
1> <<24930>> =:= <<98>>.
true
 
 
I'm using OTP-21.3.7.
 

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Equal binaries with different integers

Ivan Uemlianin
 > 24930 rem 256.
98

On 29/04/2019 09:21, DOBRO wrote:
> <<24930>> =:= <<98>>.

--
============================================================
Ivan A. Uemlianin PhD
Llaisdy

Ymchwil a Datblygu Technoleg Lleferydd
Speech Technology Research and Development

                     [hidden email]
                         @llaisdy
                          llaisdy.wordpress.com
               github.com/llaisdy
                      www.linkedin.com/in/ivanuemlianin

                         festina lente
============================================================

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Equal binaries with different integers

Bob Ippolito
In reply to this post by DOBRO
It's possible because the default size for an integer in bit syntax is 8.

1> 24930 rem 256 =:= 98.
true

For further explanation of this behavior you can take a look at this section of the documentation: http://erlang.org/doc/programming_examples/bit_syntax.html#Defaults

-bob

On Mon, Apr 29, 2019 at 1:27 AM DOBRO <[hidden email]> wrote:
Hi,
could anyone explain me how is it possible?
 
In shell:
 
1> <<24930>> =:= <<98>>.
true
 
 
I'm using OTP-21.3.7.
 
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Equal binaries with different integers

DOBRO
Thanks for the answers.
Well, it is not obvious at first sight :)
 
 
29.04.2019, 11:31, "Bob Ippolito" <[hidden email]>:
It's possible because the default size for an integer in bit syntax is 8.
 
1> 24930 rem 256 =:= 98.
true
 
For further explanation of this behavior you can take a look at this section of the documentation: http://erlang.org/doc/programming_examples/bit_syntax.html#Defaults
 
-bob
 
On Mon, Apr 29, 2019 at 1:27 AM DOBRO <[hidden email]> wrote:
Hi,
could anyone explain me how is it possible?
 
In shell:
 
1> <<24930>> =:= <<98>>.
true
 
 
I'm using OTP-21.3.7.
 
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Equal binaries with different integers

zxq9-2
In reply to this post by DOBRO
On 2019年4月29日月曜日 11時21分33秒 JST DOBRO wrote:
> Hi,
> could anyone explain me how is it possible?
>  
> In shell:
>  
> 1> <<24930>> =:= <<98>>.
> true


Your trying to put 24930 into a space that can hold a max value of 255.
If you want that entire value to be represented you have to give it enough ROOM (in terms of bits) to reside there.

Contemplate the following carefully:

1> <<0>>.
<<0>>
2> <<0:8>>.
<<0>>
3> <<0:32>>.
<<0,0,0,0>>
4> <<1:32>>.
<<0,0,0,1>>
5> <<255:32>>.
<<0,0,0,255>>
6> <<256:32>>.
<<0,0,1,0>>
7> <<24930:32>>.
<<0,0,97,98>>
8> <<_:24, 98:8>> = <<24930:32>>.
<<0,0,97,98>>

-Craig
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Equal binaries with different integers

empro2
Please

> Contemplate the following carefully:

On Wed, 01 May 2019 16:34:15 +0900
[hidden email] wrote:

> Your trying to put 24930 into a space that can hold a max
> value of 255.

Your use of the symbol "Your" made me run full speed into
the full stop and spend a brief period backtracking and
inferring replacement of "Your" (bound to 'second person
possessive') with "You're" or "You are", because
otherwise your sentence only noun phrase :-)

Michael

--

That which was said, is not that which was spoken,
but that which was understood; and none of these
comes necessarily close to that which was meant.









_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Equal binaries with different integers

dieter
"Trying" can be used as a noun, so it makes sense.

On the technical part of Craig's examples:
I like the erlang bit/binary syntax a lot, it allowed me to parse packet headers of binary socket protocols 
with (nearly) oneliners, compared to nasty bit-shifting and masking in C.

dieter

Am Do., Mai 2, 2019 15:17 schrieb [hidden email]:
Please

Contemplate the following carefully:


On Wed, 01 May 2019 16:34:15 +0900
[hidden email] wrote:

Your trying to put 24930 into a space that can hold a max
value of 255.


Your use of the symbol "Your" made me run full speed into
the full stop and spend a brief period backtracking and
inferring replacement of "Your" (bound to 'second person
possessive') with "You're" or "You are", because
otherwise your sentence only noun phrase :-)

Michael

--

That which was said, is not that which was spoken,
but that which was understood; and none of these
comes necessarily close to that which was meant.

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Equal binaries with different integers

Aurelian Dragomir
Yes

On Fri, May 3, 2019, 12:51 <[hidden email]> wrote:
"Trying" can be used as a noun, so it makes sense.

On the technical part of Craig's examples:
I like the erlang bit/binary syntax a lot, it allowed me to parse packet headers of binary socket protocols 
with (nearly) oneliners, compared to nasty bit-shifting and masking in C.

dieter

Am Do., Mai 2, 2019 15:17 schrieb [hidden email]:
Please

Contemplate the following carefully:


On Wed, 01 May 2019 16:34:15 +0900
[hidden email] wrote:

Your trying to put 24930 into a space that can hold a max
value of 255.


Your use of the symbol "Your" made me run full speed into
the full stop and spend a brief period backtracking and
inferring replacement of "Your" (bound to 'second person
possessive') with "You're" or "You are", because
otherwise your sentence only noun phrase :-)

Michael

--

That which was said, is not that which was spoken,
but that which was understood; and none of these
comes necessarily close to that which was meant.

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Equal binaries with different integers

empro2
In reply to this post by dieter
On Fri, 03 May 2019 09:51:39 +0000
[hidden email] wrote:

> "Trying" can be used as a noun,

True, then it is called a "gerund".

> so it makes sense.

False, when it was a gerund the line is a sole
noun phrase. Here it was meant as a present participle
being part of a present progressive but lacking the "are"
which got fused to the "You" caused by phonetic similarity
or possibly by some electric spelling correction.

But that "mistake" in itself was of little importance to
me, what was can be found there:

<http://erlang.org/pipermail/erlang-questions/2019-May/097865.html>


> I like the erlang bit/binary syntax a lot, it allowed me

So do I. I also liked zxq9's explanation, Erlang
(particularly its lack of loops and its "ugliness"), and
not least the people on this list :-)

Michael

--

You do not live in your environment,
you are part of it.












_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Equal binaries with different integers

zxq9-2
In reply to this post by dieter
On 2019年5月3日金曜日 9時51分39秒 JST [hidden email] wrote:
> "Trying" can be used as a noun, so it makes sense.
> On the technical part of Craig's examples:
> I like the erlang bit/binary syntax a lot, it allowed me to parse packet headers of binary socket protocols
> with (nearly) oneliners, compared to nasty bit-shifting and masking in C.
> dieter

Yes, but Michael is right. I had originally started my reply with something like "Your example..." and then changed my approach, edited my sentence, and never properly re-wrote it from the beginning.
Whoops!

I try to make an effort to write properly because many readers are not native English speakers. Analogous typos (and slang) in Japanese and German occasionally throw me for a loop as well, so I have a lot of sympathy for feelings of annoyance at these kinds of mistakes.

Sorry about the confusion!
Hopefully the example in Erlang was clearer than my poorly written English.

-Craig
_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Equal binaries with different integers

empro2
On Mon, 06 May 2019 18:51:53 +0900
[hidden email] wrote:

> for a loop as well, so I have a lot of sympathy for
> feelings of annoyance at these kinds of mistakes.

No annoyance at all on my part:

http://erlang.org/pipermail/erlang-questions/2019-May/097865.html


> Sorry about the confusion!

No need at all, the confusion may well have been limited to
one single brain. Asked a friend to read the sentence,
asked for the meaning and she had uncounsciously performed
the necessary replacement, simply had not read what was
written there ...


> my poorly written English.

Glad I am not the only one who likes to exaggerate.

~Michael

--

You do not live in your environment,
you are part of it.








_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions