Symbol or Convention for Representing Endianness? -
is there symbol, or other convention, indicating endianness of value/variable/what-have-you in technical writing?
that is, if wanted describe algorithm or formula, , represent formula mathematical expression (e.g. x = p + 2 / y), there way of indicating endianness of 1 of variables?
for example:
the following formula shows how calculate new pointer value,
npnt
.when working old pointer value, stored in
int
variablepnt
, keep in mind stored little-endian, whilenew
,offset
big endian. in order perform mathematical operations using value ofpnt
, must changepnt
big-endian.
int pnt = 0x1722
int new = 0x900f
int offset = 0xf600
npnt = offset + new - pnt
this random example. main thing concerned formula - without paragraph explanation above, there no indication of endianness of each variable in formula.
the solution came superscript arrow symbol variables so:
npnt→ = offset→ + new→ - pnt←
or, better yet, put arrows directly above variable names (which can't quite using limited html of so).
is there convention that? or never done because i'm describing/representing things wrong in first place?
for cross-platform code base worked on, used convention of appending _be
variables in big-endian byte order , _le
in little-endian byte order. else assumed in host byte order.
structures created networking protocols used naming, clear byte order dealing with. had deal both big , little endian values, , sticking convention helped greatly.
if you're consistent, it's hard make mistakes in code. assigning foo_be
bar
sticks out wrong, , bar = be16toh( foo_be)
looks right.
if you're using formatted text, use sub-scripted be
or le
on value or variable not in host byte order.
Comments
Post a Comment