On 07/20/23 04:57AM, NRK wrote:
> 
> C standard defines shift operator as multiplication and division by
> powers of 2. And the result of `x * 256` never depend on the system's
> byte order and so neither does `x << 8`.
> 
> Rob Pike already has an excellent article on this, so I'll just refer to
> that: https://commandcenter.blogspot.com/2012/04/byte-order-fallacy.html
> 

I now realize that I was not right. You're correct.

> > Instead, one can use htons(byteorder.3).
> 
> If anything, those functions are precisely the source of confusion like
> these and should be avoided for this reason.
> 

I meant `ntohs`... and this further proves your point.
Thank you for your insight & for the article.

Jeremy

Reply via email to