I’m curious how binary-size(8)
and size(64)
differ, because I’m getting different results than I’d expect.
Specifically, I’d expect identical results from each, but I might be missing some detail.
As a quick example:
iex(50)> a = "hello world"
"hello world"
iex(51)> <<h::binary-size(8), _rest::binary>> = a
"hello world"
iex(52)> h
"hello wo"
iex(53)> <<h2::size(64), _rest::binary>> = a
"hello world"
iex(54)> h2
7522537965568948079
Why is there a discrepancy in the results of these matches, given that size()
measures in bits and binary-size()
is in bytes, which makes them ostensibly the same?
Thanks!