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

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...
  • Comment on Re^2: Use pack to create a float in non-native format

Replies are listed 'Best First'.
Re^3: Use pack to create a float in non-native format
by BrowserUk (Patriarch) on Feb 07, 2010 at 12:26 UTC

    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.