Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Converting bytes to floats

by ikegami (Patriarch)
on Apr 17, 2023 at 18:23 UTC ( [id://11151715]=note: print w/replies, xml ) Need Help??


in reply to Converting bytes to floats

I believe you're asking for

say for unpack "d*", $contents;

unpack

Mini-Tutorial: Formats for Packing and Unpacking Numbers

Replies are listed 'Best First'.
Re^2: Converting bytes to floats
by Anonymous Monk on Apr 17, 2023 at 19:28 UTC
    It's a series of bytes. This powershell works:
    $len = $bytes.Count/8 for( $i = 0 ; $i -lt $len ; $i++) { [System.BitConverter]::ToDouble($bytes, $i * 8 ) }
        Did you try what I provided?

        I think it's theoretically possible that the OP did follow the advice but struck an endianness issue which, to be resolved, would presumably require either:
        unpack "d<*", $contents or unpack "d>*", $contents
        Cheers,
        Rob
      Yes, I think, what you are looking for is $number = unpack('d', $bytes);

      If $bytes hold 8 bytes, then unpack will convert that to a number.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11151715]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2024-04-25 15:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found