Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Network IEEE 754 to Native Floats: which pack/unpack ops better?

by Roger (Parson)
on Nov 25, 2003 at 22:55 UTC ( [id://310088]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
     packing float as network long:
     +-----+    +-----------+    +------------+
    ...
     +------------+    +-----------+    +-----+
     |network long|--->|native long|--->|float|
     +------------+    +-----------+    +-----+
    
  2. or download this
    use strict;
    use IO::File;
    ...
      my $float = unpack 'f', pack 'L', unpack 'N', $network_long;
      printf "%0.4f\n", $float;
    }
    
  3. or download this
    On SUN: float->network_long->disk
    On WindowsXP: disk->network_long->float
    
  4. or download this
    On WindowsXP: float->network_long->disk
    On SUN: disk->network_long->float
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (10)
As of 2024-03-29 15:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found