Did you know ... | Search Documentation: |
![]() | Pack canny_tudor -- prolog/dcg/endian.pl |
big
or little
-endian ordering grammar to an integer
Value of any Width.
Divides the problem in two: firstly the 'endianness' span which unifies an input or output phrase with the bit width of a value, and secondly the shifted bitwise-OR phase that translates between coded eight-bit octets and un-encoded integers of unlimited bit width by accumulation.
endian(big, Width, Value)
super-grammar.
In (-, +) mode the accumulator recurses first and then the
residual Value_ merges with the accumulated Value because the first
octet code is the most-significant byte of the value for big-endian
integer representations, rather than the least-significant. The 0
=< H, H =< 255
guard conditions ensure failure for non-octet code
items in the list.
endian(little, Width, Value)
grammar.
Little-endian accumulators perform the same logical unification as for big-endian only in reverse. The only difference between big and little: recurse first or recurse last. Apart from that subtle but essential difference, the inner computation behaves identically.