in reply to Re: Understanding endianness of a number
in thread Understanding endianness of a number
Thanks a boatload, haukex!
After I wrote my question here, I continued doing research. I was comparing endianness with the year long work I've been doing with hardware registers, so I could not quite grasp things until it did click (then you re-affirmed) that endianness (mostly) refers to byte storage, not (typically) bit storage.
By the time I wrote my post here, I thought I had it, but just wanted clarification. You covered it perfectly, even down to sometimes bits, and how some 32 or 64 bit ints may even have the middle bytes reversed. I think I'll leave that for another day until I run into it, if ever. :)
I also agree with your shift first then perform and/or-ing. I ran into that while playing around during this whole lesson. Not only can it catch edge case problems, I feel it's quicker to digest/comprehend when glancing through code. Thanks for that tidbit too.
The endianness issue cropped up because I was getting weird (read: backwards) results when trying to read two bytes as a single 16-bit int from an Arduino over I2C. This case is present in this post that I made, within the Arduino sketch portion of it, within the __read_analog() function.
Thanks again,
-stevieb
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Understanding endianness of a number
by haukex (Archbishop) on Jul 23, 2017 at 20:14 UTC | |
by stevieb (Canon) on Jul 23, 2017 at 20:18 UTC | |
|
Re^3: Understanding endianness of a number
by Marshall (Canon) on Jul 23, 2017 at 22:04 UTC | |
by stevieb (Canon) on Jul 23, 2017 at 22:20 UTC | |
by Marshall (Canon) on Jul 24, 2017 at 03:05 UTC | |
by RonW (Parson) on Jul 26, 2017 at 22:17 UTC | |
by Anonymous Monk on Jul 27, 2017 at 17:04 UTC | |
by choroba (Cardinal) on Jul 27, 2017 at 17:56 UTC | |
by Anonymous Monk on Jul 27, 2017 at 19:32 UTC | |
|