in reply to Re: Perl binary file
in thread Perl binary file
'd' or 'D'These are C double and long double, respectively. They are probably different. On Intel machines, long double is usually an 80-bit non-IEEE754 type while double is standard IEEE-754 double precision type.
'f' and 'F'These are C float and "whatever Perl uses internally". Again, on Intel machines float usually represents IEEE-754 single precision type, while NV would be even less portable than long double (because a user could rebuild their Perl with different definition for NV) but priceless for exact data caching in between the runs of your own application.
To answer your original question, use f for IEEE-754 single precision, d for IEEE-754 double precision types compatible with C and VB (if float and double do not correspond to IEEE types on a given system, chances are it doesn't support IEEE types at all and such processors are rare enough that you probably shouldn't worry about them) and > for big-endian (most significant byte first; "network byte order"), < for little-endian (least significant byte first; "Intel byte order"). Also, you were right, to sequentially append to binary files, just use open (my $fh, ">>:raw", $filename);.
|
|---|