in reply to Use pack to create a float in non-native format

A guess based upon my reading of Table 2.5 and the preceding paragraph. I've no way to check it.

$SPARCfloat = pack 'a4a4', reverse unpack 'a4a4', pack 'f', 1222222345 +.678e9;;

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"I'd rather go naked than blow up my ass"

Replies are listed 'Best First'.
Re^2: Use pack to create a float in non-native format
by mjscott2702 (Pilgrim) on Feb 07, 2010 at 09:58 UTC
    Well, I tried it (actually needed single-format floats i.e. 32-bits, so adjusted accordingly) - my guess is that the bits were reversed from what they needed to be. Which brings me on to the next response...

      I didn't think to try the built-in big-endian conversion, because you said you'd already tried reversing the bytes. And that's all it does.

      I missed that you'd forgotten the scalar context requirement:

      print unpack 'H*', pack 'f>', 123.456;; 42f6e979 print unpack 'H*', scalar reverse pack 'f', 123.456;; 42f6e979

      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.