>>>>> "BRH" == Bryan R Harris <bryan_r_har...@raytheon.com> writes:

  BRH> Maybe this is just my own ignorance on big-endian vs. little endian, but
  BRH> this code:

  BRH>   print "big-endian:     ", unpack("H*", pack("d", -3205.0569059)), "\n";
  BRH>   print "little-endian:  ", unpack("h*", pack("d", -3205.0569059)), "\n";

  BRH> prints:

  BRH>   big-endian:     e626c5221d0aa9c0
  BRH>   little-endian:  6e625c22d1a09a0c

note that those are the same bytes but each byte is printed with
different ordering for the hex digits.

the docs say this:

                   h   A hex string (low nybble first).
                   H   A hex string (high nybble first).

and a nybble (or nibble) is a single hex digit of 4 bits and there are
two in a byte. the h vs H only changes the nibble order in a byte. this
has nothing to do with endian issues which are a byte ordering thing.

pack doesn't have a direct way to deal with endians with floats. you can
just use reverse on the byte string to control that. that is what i do
in Sort::Maker for this. did you look at that module yet? as i keep
saying it does exactly what you are trying to do so you can learn from it.

uri

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to