Help for this page

Select Code to Download


  1. or download this
    $ perl -we 'my $pi = 4*atan2(1,1);
                print pack "f", $pi' > le-pi.bin
    $ od -h le-pi.bin 
    0000000 0fdb 4049
    0000004
    
  2. or download this
    $ perl -we 'my $buf;
                read STDIN, $buf, 4;
                my $pi = unpack "f", reverse $buf;
                print "pi=$pi\n";' < le-pi.bin
    pi=3.14159274101257
    
  3. or download this
      # reverse endianness of first 4-byte float:
      substr( $buf, 0, 4 ) = reverse substr( $buf, 0, 4 );